kysely adapter pretty much working!

This commit is contained in:
Alex Gleason 2023-08-06 20:22:12 -05:00
parent d799075657
commit 465a3db501
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
3 changed files with 9 additions and 8 deletions

View File

@ -10,14 +10,14 @@
"@/": "./src/"
},
"lint": {
"include": ["src/"],
"include": ["src/", "lib/"],
"rules": {
"tags": ["recommended"],
"exclude": ["no-explicit-any"]
}
},
"fmt": {
"include": ["src/"],
"include": ["src/", "lib/"],
"useTabs": false,
"lineWidth": 120,
"indentWidth": 2,

View File

@ -28,14 +28,18 @@ class DenoSqliteDatabase implements SqliteDatabase {
}
prepare(sql: string): SqliteStatement {
const query = this.#db.prepareQuery(sql);
return {
// HACK: implement an actual driver to fix this.
reader: true,
all: (parameters: ReadonlyArray<unknown>) => {
console.log(sql);
return this.#db.query(sql, parameters as any);
const result = query.allEntries(parameters as any);
query.finalize();
return result;
},
run: (parameters: ReadonlyArray<unknown>) => {
this.#db.query(sql, parameters as any);
query.execute(parameters as any);
query.finalize();
return {
changes: this.#db.changes,
lastInsertRowid: this.#db.lastInsertRowId,

View File

@ -1,4 +1,3 @@
import { builder } from '@/db/builder.ts';
import { type Filter, Sqlite } from '@/deps.ts';
import { SignedEvent } from '@/event.ts';
@ -111,6 +110,4 @@ const db = new DittoDB(
new Sqlite('data/db.sqlite3'),
);
console.log(await builder.selectFrom('events').selectAll().limit(1).execute())
export { db };