From f99ea7c33fa4cf385513a487df164b48ea1d3f71 Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Fri, 13 Sep 2024 18:57:47 -0300 Subject: [PATCH] refactor(getPubkeysBySearch): cast as string --- src/controllers/api/search.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/api/search.ts b/src/controllers/api/search.ts index c778bc4f..d62c08e8 100644 --- a/src/controllers/api/search.ts +++ b/src/controllers/api/search.ts @@ -198,12 +198,12 @@ async function getLookupFilters({ q, type, resolve }: SearchQuery, signal: Abort /** Get pubkeys whose name and NIP-05 is similar to 'q' */ async function getPubkeysBySearch(kysely: Kysely, { q, limit }: Pick) { - const pubkeys = (await sql` + const pubkeys = (await sql<{ pubkey: string }>` SELECT *, word_similarity(${q}, search) AS sml FROM author_search WHERE ${q} % search ORDER BY sml DESC, search LIMIT ${limit} - `.execute(kysely)).rows.map((row) => (row as { pubkey: string }).pubkey); + `.execute(kysely)).rows.map(({ pubkey }) => pubkey); return pubkeys; }