0.2.2 • Published 1 month ago

@subframe7536/sqlite-wasm v0.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

sqlite-wasm

typesafe wa-sqlite wrapper, run in memory or persist data to IndexedDB or OPFS

low-level layer for kysely-wasqlite-worker-dialect

Usage

Memory

use MemoryVFS with wa-sqlite.wasm, no data persistence

import { getSyncWasmURL, initSQLite, isOpfsSupported, useMemoryStorage } from '@subframe7536/sqlite-wasm'

// optional url
const url = 'https://cdn.jsdelivr.net/gh/rhashimoto/wa-sqlite@v0.9.9/dist/wa-sqlite.wasm'

const { run, changes, lastInsertRowId, close } = await initSQLite(
  useMemoryStorage({ url })
)

IndexedDB

use IDBBatchAtomicVFS with wa-sqlite-async.wasm, larger than sync version, better compatibility

minimal IndexedDB backend browser version

import { useIdbStorage } from '@subframe7536/sqlite-wasm/idb'
import { getAsyncWasmURL, initSQLite } from '@subframe7536/sqlite-wasm'

// optional url
const url = 'https://cdn.jsdelivr.net/gh/rhashimoto/wa-sqlite@v0.9.9/dist/wa-sqlite-async.wasm'

const { run, changes, lastInsertRowId, close } = await initSQLite(
  useIdbStorage('IndexedDB', { url })
)

OPFS

use AccessHandlePoolVFS with wa-sqlite.wasm, smaller than async version

minimal OPFS backend browser version

MUST RUN IN WEB WORKER

import { getSyncWasmURL, initSQLite, isOpfsSupported } from '@subframe7536/sqlite-wasm'
import { useOpfsStorage } from '@subframe7536/sqlite-wasm/opfs'

// optional url
const url = 'https://cdn.jsdelivr.net/gh/rhashimoto/wa-sqlite@v0.9.9/dist/wa-sqlite.wasm'

onmessage = async () => {
  if (!await isOpfsSupported()) { // this can be called in main thread
    return
  }
  const { run, changes, lastInsertRowId, close } = await initSQLite(
    useOpfsStorage('OPFS', url)
  )
}
0.2.2

1 month ago

0.2.1

5 months ago

0.2.0

6 months ago

0.1.9

6 months ago

0.1.8

6 months ago

0.1.6

6 months ago

0.1.5

6 months ago

0.1.4

6 months ago

0.1.3

6 months ago

0.1.2

6 months ago

0.1.1

6 months ago

0.1.0

6 months ago

0.0.3

6 months ago

0.0.2

6 months ago

0.0.1

6 months ago