Switch to NPostgres (steamroll SQLite for now)

This commit is contained in:
Alex Gleason 2024-08-10 13:30:24 -05:00
parent 66cfba5535
commit 916b68a3e4
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
3 changed files with 9 additions and 11 deletions

View file

@ -30,7 +30,7 @@
"@isaacs/ttlcache": "npm:@isaacs/ttlcache@^1.4.1", "@isaacs/ttlcache": "npm:@isaacs/ttlcache@^1.4.1",
"@lambdalisue/async": "jsr:@lambdalisue/async@^2.1.1", "@lambdalisue/async": "jsr:@lambdalisue/async@^2.1.1",
"@noble/secp256k1": "npm:@noble/secp256k1@^2.0.0", "@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", "@nostrify/nostrify": "jsr:@nostrify/nostrify@^0.30.0",
"@scure/base": "npm:@scure/base@^1.1.6", "@scure/base": "npm:@scure/base@^1.1.6",
"@sentry/deno": "https://deno.land/x/sentry@7.112.2/index.mjs", "@sentry/deno": "https://deno.land/x/sentry@7.112.2/index.mjs",

8
deno.lock generated
View file

@ -11,7 +11,7 @@
"jsr:@gleasonator/policy@0.4.1": "jsr:@gleasonator/policy@0.4.1", "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:@hono/hono@^4.4.6": "jsr:@hono/hono@4.5.3",
"jsr:@lambdalisue/async@^2.1.1": "jsr:@lambdalisue/async@2.1.1", "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.1": "jsr:@nostrify/nostrify@0.22.5",
"jsr:@nostrify/nostrify@^0.22.4": "jsr:@nostrify/nostrify@0.22.4", "jsr:@nostrify/nostrify@^0.22.4": "jsr:@nostrify/nostrify@0.22.4",
"jsr:@nostrify/nostrify@^0.22.5": "jsr:@nostrify/nostrify@0.22.5", "jsr:@nostrify/nostrify@^0.22.5": "jsr:@nostrify/nostrify@0.22.5",
@ -138,8 +138,8 @@
"@lambdalisue/async@2.1.1": { "@lambdalisue/async@2.1.1": {
"integrity": "1fc9bc6f4ed50215cd2f7217842b18cea80f81c25744f88f8c5eb4be5a1c9ab4" "integrity": "1fc9bc6f4ed50215cd2f7217842b18cea80f81c25744f88f8c5eb4be5a1c9ab4"
}, },
"@nostrify/db@0.30.0": { "@nostrify/db@0.31.0": {
"integrity": "a75ba78be89d57c54c3d47e9e94c7142817c5b50daec27bf7f9a4af4629be20b", "integrity": "e1621f553aae431ad1d592de40684767b48ebc0b77cd36498eb92101c40374f0",
"dependencies": [ "dependencies": [
"jsr:@nostrify/nostrify@^0.30.0", "jsr:@nostrify/nostrify@^0.30.0",
"jsr:@nostrify/types@^0.30.0", "jsr:@nostrify/types@^0.30.0",
@ -1827,7 +1827,7 @@
"jsr:@db/sqlite@^0.11.1", "jsr:@db/sqlite@^0.11.1",
"jsr:@hono/hono@^4.4.6", "jsr:@hono/hono@^4.4.6",
"jsr:@lambdalisue/async@^2.1.1", "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:@nostrify/nostrify@^0.30.0",
"jsr:@soapbox/kysely-deno-sqlite@^2.1.0", "jsr:@soapbox/kysely-deno-sqlite@^2.1.0",
"jsr:@soapbox/stickynotes@^0.4.0", "jsr:@soapbox/stickynotes@^0.4.0",

View file

@ -1,6 +1,6 @@
// deno-lint-ignore-file require-await // deno-lint-ignore-file require-await
import { NDatabase } from '@nostrify/db'; import { NPostgres } from '@nostrify/db';
import { import {
NIP50, NIP50,
NKinds, NKinds,
@ -33,7 +33,7 @@ type TagCondition = ({ event, count, value }: {
/** SQLite database storage adapter for Nostr events. */ /** SQLite database storage adapter for Nostr events. */
class EventsDB implements NStore { class EventsDB implements NStore {
private store: NDatabase; private store: NPostgres;
private console = new Stickynotes('ditto:db:events'); private console = new Stickynotes('ditto:db:events');
/** Conditions for when to index certain tags. */ /** Conditions for when to index certain tags. */
@ -54,11 +54,9 @@ class EventsDB implements NStore {
}; };
constructor(private kysely: Kysely<DittoTables>) { constructor(private kysely: Kysely<DittoTables>) {
this.store = new NDatabase(kysely, { this.store = new NPostgres(kysely, {
fts: Conf.db.dialect,
timeoutStrategy: Conf.db.dialect === 'postgres' ? 'setStatementTimeout' : undefined,
indexTags: EventsDB.indexTags, indexTags: EventsDB.indexTags,
searchText: EventsDB.searchText, indexSearch: EventsDB.searchText,
}); });
} }