db/relays: skip if values are empty

This commit is contained in:
Alex Gleason 2023-08-14 19:00:54 -05:00
parent e3ade42f58
commit b11677573b
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 1 additions and 0 deletions

View File

@ -2,6 +2,7 @@ import { db } from '@/db.ts';
/** Inserts relays into the database, skipping duplicates. */ /** Inserts relays into the database, skipping duplicates. */
function addRelays(relays: `wss://${string}`[]) { function addRelays(relays: `wss://${string}`[]) {
if (!relays.length) return Promise.resolve();
const values = relays.map((url) => ({ url })); const values = relays.map((url) => ({ url }));
return db.insertInto('relays') return db.insertInto('relays')