-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Thanks for the lib, it works like charm 😄
Btw, I read the code and see only the query tag from init.js (https://github.com/WebReflection/sqlite-worker/blob/main/esm/init.js#L96) triggers the update callback timer.
I tried the transaction
tag and it doesn't work
// no ?module needed, it's the main export in unpkg
import { init } from "//unpkg.com/sqlite-worker";
// `dist` option resolved automatically via import.meta.url
init({
name: "my-db1",
update(uInt8Array) {
console.log("updated", uInt8Array);
},
}).then(async ({ all, get, query, raw, transaction }) => {
const table = raw`todos`;
await query`CREATE TABLE IF NOT EXISTS ${table} (id INTEGER PRIMARY KEY, value TEXT)`;
const { total } = await get`SELECT COUNT(id) as total FROM ${table}`;
if (total < 10) {
console.log("Inserting some value");
await query`INSERT INTO ${table} (value) VALUES (${"a"})`;
await query`INSERT INTO ${table} (value) VALUES (${"b"})`;
await query`INSERT INTO ${table} (value) VALUES (${"c"})`;
}
const insert = transaction();
for (let i = 0; i < 10; i++)
insert`INSERT INTO todos (value) VALUES (${"Ipsum " + i})`;
await insert.commit();
console.log(await all`SELECT * FROM ${table}`);
});
Can we export a defer update function, save function to manual trigger save ?
Thanks
Metadata
Metadata
Assignees
Labels
No labels