Skip to content

Commit 2f62c71

Browse files
authored
Merge pull request #282 from levydsa/read_your_writes
feat: add readYourWrites to options
2 parents 1e77794 + 4073452 commit 2f62c71

File tree

6 files changed

+400
-0
lines changed

6 files changed

+400
-0
lines changed

examples/read-your-writes/package-lock.json

+351
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "read-your-writes",
3+
"version": "1.0.0",
4+
"main": "index.mjs",
5+
"author": "Levy Albuquerque",
6+
"license": "MIT",
7+
"dependencies": {
8+
"@libsql/client": "^0.14.0"
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { createClient } from "@libsql/client";
2+
3+
const client = createClient({
4+
url: "file:local.db",
5+
syncUrl: process.env.TURSO_DATABASE_URL,
6+
authToken: process.env.TURSO_AUTH_TOKEN,
7+
readYourWrites: false,
8+
});
9+
10+
await client.execute("DROP TABLE users");
11+
await client.execute("CREATE TABLE IF NOT EXISTS users (email TEXT)");
12+
await client.sync();
13+
14+
await client.execute("INSERT INTO users VALUES ('[email protected]')");
15+
await client.execute("INSERT INTO users VALUES ('[email protected]')");
16+
await client.execute("INSERT INTO users VALUES ('[email protected]')");
17+
18+
{
19+
// No users, sinc no sync has happend since inserts
20+
const result = await client.execute("SELECT * FROM users");
21+
22+
console.log("Users:", result.rows);
23+
}
24+
25+
{
26+
await client.sync();
27+
28+
// No users, sinc no sync has happend since inserts
29+
const result = await client.execute("SELECT * FROM users");
30+
31+
console.log("Users:", result.rows);
32+
}

0 commit comments

Comments
 (0)