kysely-wasm
v2.0.0
Published
kysely dialect for various sqlite wasm
Maintainers
Readme
kysely-wasm
kysely dialect for various SQLite wasm
no wasm denpendencies, your need to install yourself
Install
bun add -d kysely kysely-wasmIntroduce
there are 6 dialects
- SqlJsDialect: dialect for sql.js
- OfficialWasmDialct: dialect for official wasm build
- NodeWasmDialct: dialect for node sqlite3 wasm
- EmptyDialect: only for sql generation, no backend
- CrsqliteDialect: dialect for vlcn.io/wasm ~~- WaSqliteDialect: dialect for wa-sqlite~~
Differences
SqlJsDialect: easy to use
you can get total buffer on every sql execution except select and no backend storage
- no support for bigint
OfficialWasmDialect: performance
you can choose to use OPFS as backend storage(for some vfs, your server must response COOP and COEP in header, see doc), which is recommended officially (see this and this) and only work in WebWorker.
The dialect executes Kysely queries with the official prepared-statement API (prepare, bind, step, get, finalize) instead of the higher-level exec helper. stream()/streamQuery() reuses the same low-level path and finalizes statements in a finally block, so large select results can be consumed incrementally instead of first collecting every row into an array.
const rows = db.selectFrom('person').selectAll().stream()
for await (const row of rows) {
console.log(row)
}WaSqliteDialect: polyfill
deprecated, you can choose to use worker dialect
NodeWasmDialect: no compile
you can choose to use native file system as backend storage, which is no need to recompile for different platform
CrsqliteDialect: CRDT
you can choose to use IndexedDB as backend storage
Type
see in jsdoc
Usage and more details
see test and playground
