refactor: use db.kysely.updateTable rather than db.kysely.insertInto

This commit is contained in:
P. Reis 2025-03-05 20:12:42 -03:00
parent 19244aec2c
commit 1eb1f4206d

View file

@ -161,7 +161,7 @@ export class DittoRelayStore implements NRelay {
} }
// Recheck encountered after async ops. // Recheck encountered after async ops.
if (this.encounters.has(event.id)) { if (this.encounters.has(event.id)) {
throw new RelayError('duplicate', 'already have this event'); return;
} }
// Set the event as encountered after verifying the signature. // Set the event as encountered after verifying the signature.
this.encounters.set(event.id, true); this.encounters.set(event.id, true);
@ -293,23 +293,17 @@ export class DittoRelayStore implements NRelay {
return; return;
} }
await db.kysely.insertInto('author_stats') try {
.values({ await db.kysely.updateTable('author_stats').set({
pubkey: author.pubkey, nip05: null,
followers_count: 0, nip05_domain: null,
following_count: 0, nip05_hostname: null,
notes_count: 0, nip05_last_verified_at: author.created_at,
search: '', }).where('pubkey', '=', author.pubkey)
}) .execute();
.onConflict((oc) => } catch {
oc.column('pubkey').doUpdateSet({ // nothing hahah
nip05: null, }
nip05_domain: null,
nip05_hostname: null,
nip05_last_verified_at: author.created_at,
})
)
.execute();
} }
/** Parse kind 0 metadata and track indexes in the database. */ /** Parse kind 0 metadata and track indexes in the database. */