Skip to content

A deno module wrapping `x/sqlite` in a worker for async operation.

License

Notifications You must be signed in to change notification settings

xyzshantaram/worker-sqlite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

worker-sqlite

A deno module wrapping x/sqlite in a worker for async operation.

Note: This library makes use of unstable APIs, and must be run with the --unstable flag.

Usage

Import with

import { WorkerSqliteDb } from "https://deno.land/x/[email protected]/mod.ts";

Then create a DB object, execute and query things!

const db = new WorkerSqliteDb("./example.db");
await db.query("select things from table"); // Returns an array of RowObjects, i.e. objects representing rows as sets of key-value pairs.
await db.execute("delete things from table where condition = ?", condition);

Finally, close the db.

// will throw an Error if there are pending queries!
await db.close();

Write-ahead logging and using the sqlite3 module

The sqlite3 module is an alternative SQLite library for Deno, using the Deno FFI instead of WASM to run SQLite. It supports write-ahead logging, and is thus a better choice for applications that do a lot of writing to the DB. You can enable the use of this module by passing a backend argument in the options to the WorkerSqliteDb constructor.

const db = new WorkerSqliteDb("./example-2.db", {
  backend: "sqlite3",
});

License

This module is free software under the MIT License. Copyright © 2022 Siddharth Singh.

About

A deno module wrapping `x/sqlite` in a worker for async operation.

Resources

License

Stars

Watchers

Forks

Packages

No packages published