JSPM

@vicary/kysely-libsql

0.5.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q31180F
  • License MIT

Kysely dialect for libSQL

Package Exports

  • @vicary/kysely-libsql

Readme

kysely-libsql

A Kysely dialect for libSQL, compatible with @libsql/client.

Installation

npm install @libsql/kysely-libsql

Usage

Pass a LibsqlDialect instance as the dialect when creating the Kysely object:

import { Kysely } from "kysely";
import { LibsqlDialect } from "@libsql/kysely-libsql";

interface Database {
    ...
}

const db = new Kysely<Database>({
    dialect: new LibsqlDialect({
        url: "libsql://localhost:8080?tls=0",
        authToken: "<token>", // optional
    }),
});

Instead of a url, you can also pass an existing Client from @libsql/client:

import { createClient } from "@libsql/client";

const client = createClient({
    url: "libsql://localhost:8080",
});

const db = new Kysely<Database>({
    dialect: new LibsqlDialect({ client }),
});

// after you are done with the `db`, you must close the `client`:
client.close();

Or pass a createClient function to have Kysely manage the client's lifecycle.

import { createClient } from "@libsql/client";

const db = new Kysely<Database>({
    createClient: () =>
        createClient({
            url: "file:local.db",
            syncUrl: "libsql://localhost:8080",
            authToken: "<token>",
        }),
});

Supported Configuration Options

The library accepts the exact same options as @libsql/client.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in @libsql/kysely-libsql by you, shall be licensed as MIT, without any additional terms or conditions.