Move @tursodatabase/sync code to sync/javascript

This commit is contained in:
Pekka Enberg
2025-08-18 14:22:00 +03:00
parent 33ddae1877
commit 13b805a992
27 changed files with 13 additions and 13 deletions

View File

@@ -0,0 +1,33 @@
import { connect } from '@tursodatabase/sync';
const db = await connect({
path: 'local.db',
url: process.env.TURSO_URL,
authToken: process.env.TURSO_AUTH_TOKEN,
clientName: 'turso-sync-example'
});
await db.sync();
console.info("database initialized and ready to accept writes")
{
console.info("data from remote")
let stmt = await db.prepare('SELECT * FROM users');
console.info(await stmt.all());
}
for (let i = 0; i < 2; i++) {
let id = Math.ceil(Math.random() * 100000);
await db.exec(`INSERT INTO users VALUES (${id}, 'random-name-${id}')`);
}
{
console.info("data after local insert")
let stmt = await db.prepare('SELECT * FROM users');
console.info(await stmt.all());
}
console.info("sync changes with the remote")
await db.sync();

View File

@@ -0,0 +1,39 @@
{
"name": "cloud",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "cloud",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"@tursodatabase/sync": "../.."
}
},
"../..": {
"name": "@tursodatabase/sync",
"version": "0.1.4-pre.2",
"license": "MIT",
"dependencies": {
"@tursodatabase/turso": "file:../../bindings/javascript"
},
"devDependencies": {
"@napi-rs/cli": "^3.0.4",
"@napi-rs/wasm-runtime": "^1.0.1",
"@types/node": "^24.2.0",
"ava": "^6.0.1",
"tsc": "^2.0.4",
"typescript": "^5.9.2"
},
"engines": {
"node": ">= 10"
}
},
"node_modules/@tursodatabase/sync": {
"resolved": "../..",
"link": true
}
}
}

View File

@@ -0,0 +1,15 @@
{
"name": "cloud",
"version": "1.0.0",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"@tursodatabase/sync": "../.."
}
}