From 916b68a3e47b70dc880d25fcc677908ed2c8024d Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 10 Aug 2024 13:30:24 -0500 Subject: [PATCH] Switch to NPostgres (steamroll SQLite for now) --- deno.json | 2 +- deno.lock | 8 ++++---- src/storages/EventsDB.ts | 10 ++++------ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/deno.json b/deno.json index ed5eca51..94df4107 100644 --- a/deno.json +++ b/deno.json @@ -30,7 +30,7 @@ "@isaacs/ttlcache": "npm:@isaacs/ttlcache@^1.4.1", "@lambdalisue/async": "jsr:@lambdalisue/async@^2.1.1", "@noble/secp256k1": "npm:@noble/secp256k1@^2.0.0", - "@nostrify/db": "jsr:@nostrify/db@^0.30.0", + "@nostrify/db": "jsr:@nostrify/db@^0.31.0", "@nostrify/nostrify": "jsr:@nostrify/nostrify@^0.30.0", "@scure/base": "npm:@scure/base@^1.1.6", "@sentry/deno": "https://deno.land/x/sentry@7.112.2/index.mjs", diff --git a/deno.lock b/deno.lock index 880f8d69..1629dbfc 100644 --- a/deno.lock +++ b/deno.lock @@ -11,7 +11,7 @@ "jsr:@gleasonator/policy@0.4.1": "jsr:@gleasonator/policy@0.4.1", "jsr:@hono/hono@^4.4.6": "jsr:@hono/hono@4.5.3", "jsr:@lambdalisue/async@^2.1.1": "jsr:@lambdalisue/async@2.1.1", - "jsr:@nostrify/db@^0.30.0": "jsr:@nostrify/db@0.30.0", + "jsr:@nostrify/db@^0.31.0": "jsr:@nostrify/db@0.31.0", "jsr:@nostrify/nostrify@^0.22.1": "jsr:@nostrify/nostrify@0.22.5", "jsr:@nostrify/nostrify@^0.22.4": "jsr:@nostrify/nostrify@0.22.4", "jsr:@nostrify/nostrify@^0.22.5": "jsr:@nostrify/nostrify@0.22.5", @@ -138,8 +138,8 @@ "@lambdalisue/async@2.1.1": { "integrity": "1fc9bc6f4ed50215cd2f7217842b18cea80f81c25744f88f8c5eb4be5a1c9ab4" }, - "@nostrify/db@0.30.0": { - "integrity": "a75ba78be89d57c54c3d47e9e94c7142817c5b50daec27bf7f9a4af4629be20b", + "@nostrify/db@0.31.0": { + "integrity": "e1621f553aae431ad1d592de40684767b48ebc0b77cd36498eb92101c40374f0", "dependencies": [ "jsr:@nostrify/nostrify@^0.30.0", "jsr:@nostrify/types@^0.30.0", @@ -1827,7 +1827,7 @@ "jsr:@db/sqlite@^0.11.1", "jsr:@hono/hono@^4.4.6", "jsr:@lambdalisue/async@^2.1.1", - "jsr:@nostrify/db@^0.30.0", + "jsr:@nostrify/db@^0.31.0", "jsr:@nostrify/nostrify@^0.30.0", "jsr:@soapbox/kysely-deno-sqlite@^2.1.0", "jsr:@soapbox/stickynotes@^0.4.0", diff --git a/src/storages/EventsDB.ts b/src/storages/EventsDB.ts index 74fa8705..ae59a948 100644 --- a/src/storages/EventsDB.ts +++ b/src/storages/EventsDB.ts @@ -1,6 +1,6 @@ // deno-lint-ignore-file require-await -import { NDatabase } from '@nostrify/db'; +import { NPostgres } from '@nostrify/db'; import { NIP50, NKinds, @@ -33,7 +33,7 @@ type TagCondition = ({ event, count, value }: { /** SQLite database storage adapter for Nostr events. */ class EventsDB implements NStore { - private store: NDatabase; + private store: NPostgres; private console = new Stickynotes('ditto:db:events'); /** Conditions for when to index certain tags. */ @@ -54,11 +54,9 @@ class EventsDB implements NStore { }; constructor(private kysely: Kysely) { - this.store = new NDatabase(kysely, { - fts: Conf.db.dialect, - timeoutStrategy: Conf.db.dialect === 'postgres' ? 'setStatementTimeout' : undefined, + this.store = new NPostgres(kysely, { indexTags: EventsDB.indexTags, - searchText: EventsDB.searchText, + indexSearch: EventsDB.searchText, }); }