Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tursodatabase/kysely-libsql
Kysely dialect for sqld
https://github.com/tursodatabase/kysely-libsql
kysely kysely-dialect libsql sqlite typescript
Last synced: about 1 month ago
JSON representation
Kysely dialect for sqld
- Host: GitHub
- URL: https://github.com/tursodatabase/kysely-libsql
- Owner: tursodatabase
- License: mit
- Created: 2023-03-03T09:51:45.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-10T09:21:37.000Z (3 months ago)
- Last Synced: 2024-09-10T11:50:13.903Z (3 months ago)
- Topics: kysely, kysely-dialect, libsql, sqlite, typescript
- Language: TypeScript
- Homepage:
- Size: 120 KB
- Stars: 42
- Watchers: 5
- Forks: 7
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# kysely-libsql
A [Kysely][kysely] dialect for [libSQL][libsql], compatible with [@libsql/client][libsql-client-ts].
[kysely]: https://github.com/koskimas/kysely
[libsql]: https://github.com/tursodatabase/libsql## Installation
```shell
npm install @libsql/kysely-libsql
```## Usage
Pass a `LibsqlDialect` instance as the `dialect` when creating the `Kysely` object:
```typescript
import { Kysely } from "kysely";
import { LibsqlDialect } from "@libsql/kysely-libsql";interface Database {
...
}const db = new Kysely({
dialect: new LibsqlDialect({
url: "libsql://localhost:8080?tls=0",
authToken: "", // optional
}),
});
```Instead of a `url`, you can also pass an existing `Client` from [`@libsql/client`][libsql-client-ts]:
```typescript
import { createClient } from "@libsql/client";const client = createClient({
url: "libsql://localhost:8080",
});const db = new Kysely({
dialect: new LibsqlDialect({ client }),
});// after you are done with the `db`, you must close the `client`:
client.close();
```## Supported Configuration Options
The library accepts the exact same [options][client-options] as [`@libsql/client`][libsql-client-ts].
[libsql-client-ts]: https://github.com/tursodatabase/libsql-client-ts
[client-options]: https://docs.turso.tech/sdk/ts/reference#initializing## 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.