Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tom-sherman/kysely-d1-api

So you can use kysely with d1 outside of cloudflare workers.
https://github.com/tom-sherman/kysely-d1-api

cloudflare-workers d1 deno sqlite

Last synced: 14 days ago
JSON representation

So you can use kysely with d1 outside of cloudflare workers.

Awesome Lists containing this project

README

        

# kysely d1 api driver

So you can use kysely with d1 outside of cloudflare workers.

> **Warning**: This is just a proof of concept. See discussion at https://github.com/aidenwallis/kysely-d1/issues/7 for more info.

```ts
export interface BlogPostsTable {
Slug: ColumnType;
Title: ColumnType;
}

interface Database {
BlogPosts: BlogPostsTable;
}

const db = new Kysely({
dialect: new D1APIDialect({
accountId: D1_ACCOUNT_ID,
apiKey: D1_API_KEY,
databaseName: D1_DB_NAME,
}),
});

const result = await db.selectFrom("BlogPosts").select("BlogPosts.Title")
.executeTakeFirstOrThrow();

console.log(result);
```