From 3c3f90eddb06132ef6d08f3e7d49035c8caf9b2c Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Sun, 27 Oct 2024 17:44:35 -0300 Subject: [PATCH] refactor: kysely.selectNoFrom --- src/utils/search.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/utils/search.ts b/src/utils/search.ts index 561eb34c..420b0812 100644 --- a/src/utils/search.ts +++ b/src/utils/search.ts @@ -1,4 +1,4 @@ -import { Kysely, type SelectExpression, sql } from 'kysely'; +import { Kysely, sql } from 'kysely'; import { DittoTables } from '@/db/DittoTables.ts'; import { NIP50 } from '@nostrify/nostrify'; @@ -44,13 +44,10 @@ export async function getIdsBySearch( ): Promise> { const { q, limit, offset } = opts; - const [lexeme] = await kysely.selectNoFrom( - sql`phraseto_tsquery(${q})` as unknown as SelectExpression, - ) - .execute() as { phraseto_tsquery: 'string' }[]; + const [lexemes] = (await sql<{ phraseto_tsquery: 'string' }>`SELECT phraseto_tsquery(${q})`.execute(kysely)).rows; // if it's just stop words, don't bother making a request to the database - if (!lexeme.phraseto_tsquery) { + if (!lexemes.phraseto_tsquery) { return new Set(); }