-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #282 from levydsa/read_your_writes
feat: add readYourWrites to options
- Loading branch information
Showing
6 changed files
with
400 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "read-your-writes", | ||
"version": "1.0.0", | ||
"main": "index.mjs", | ||
"author": "Levy Albuquerque", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@libsql/client": "^0.14.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { createClient } from "@libsql/client"; | ||
|
||
const client = createClient({ | ||
url: "file:local.db", | ||
syncUrl: process.env.TURSO_DATABASE_URL, | ||
authToken: process.env.TURSO_AUTH_TOKEN, | ||
readYourWrites: false, | ||
}); | ||
|
||
await client.execute("DROP TABLE users"); | ||
await client.execute("CREATE TABLE IF NOT EXISTS users (email TEXT)"); | ||
await client.sync(); | ||
|
||
await client.execute("INSERT INTO users VALUES ('[email protected]')"); | ||
await client.execute("INSERT INTO users VALUES ('[email protected]')"); | ||
await client.execute("INSERT INTO users VALUES ('[email protected]')"); | ||
|
||
{ | ||
// No users, sinc no sync has happend since inserts | ||
const result = await client.execute("SELECT * FROM users"); | ||
|
||
console.log("Users:", result.rows); | ||
} | ||
|
||
{ | ||
await client.sync(); | ||
|
||
// No users, sinc no sync has happend since inserts | ||
const result = await client.execute("SELECT * FROM users"); | ||
|
||
console.log("Users:", result.rows); | ||
} |
Oops, something went wrong.