@samveys/libsql

Versi
1.0.35 Nov 2026
Pasang
pnpm add @samveys/libsql

Dari packages/libsql/README.md di repository framework.

Halaman ini belum diterjemahkan. Kamu sedang membaca versi bahasa Inggris.

libSQL / Turso driver for @samveys/database. It talks to a libSQL server (sqld) over HTTP through @libsql/client, so no native addon is loaded. libSQL speaks SQLite's SQL, so the driver reuses the SQLite dialect: the query builder, schema builder and migrations behave exactly as on SQLite.

ts
import { createDatabaseManager, defineDatabaseConfig } from '@samveys/database'
import { libsql } from '@samveys/libsql'

const db = createDatabaseManager(
  defineDatabaseConfig({
    default: 'main',
    connections: { main: libsql({ url: 'http://127.0.0.1:8080' }) },
  }),
)
const rows = await db.from('users').where('id', 1).get()
console.log(rows.length)
await db.close()

For Turso, pass the database URL and token:

ts
libsql({ url: 'libsql://my-db.turso.io', authToken: process.env.TURSO_TOKEN })

Differences from SQLite

  • Cancellation: Hrana has no server-side cancel. An aborted signal rejects the query on the client; the statement may still finish on the server. The conformance cancellation cases are skipped because SQLite has no sleep() function to run their long query.
  • Isolation: one transaction runs on one Hrana stream. Pool-isolation cases are SQLite-scoped and skipped like on SQLite.
  • Streaming: rows of one statement are read in one response and then yielded one at a time.

Conformance

SVS_REQUIRE_DOCKER=1 node --no-warnings --test packages/libsql/test/conformance.test.ts starts ghcr.io/tursodatabase/libsql-server:latest, runs the 48 cases, and removes the container: 43 pass, 5 skipped (3 do not apply to SQLite, 2 cancellation).