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/" "@/": "./src/"
}, },
"lint": { "lint": {
"include": ["src/"], "include": ["src/", "lib/"],
"rules": { "rules": {
"tags": ["recommended"], "tags": ["recommended"],
"exclude": ["no-explicit-any"] "exclude": ["no-explicit-any"]
} }
}, },
"fmt": { "fmt": {
"include": ["src/"], "include": ["src/", "lib/"],
"useTabs": false, "useTabs": false,
"lineWidth": 120, "lineWidth": 120,
"indentWidth": 2, "indentWidth": 2,

View File

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

View File

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