refactor: if statement lexemes

This commit is contained in:
P. Reis 2024-10-27 15:48:04 -03:00
parent e8c66c77fc
commit d06e0311c9

View file

@ -44,13 +44,13 @@ export async function getIdsBySearch(
): Promise<Set<string>> { ): Promise<Set<string>> {
const { q, limit, offset } = opts; const { q, limit, offset } = opts;
const lexemes = await kysely.selectNoFrom( const [lexeme] = await kysely.selectNoFrom(
sql`phraseto_tsquery(${q})` as unknown as SelectExpression<DittoTables, never>, sql`phraseto_tsquery(${q})` as unknown as SelectExpression<DittoTables, never>,
) )
.execute() as { phraseto_tsquery: 'string' }[]; .execute() as { phraseto_tsquery: 'string' }[];
// if it's just stop words, don't bother making a request to the database // if it's just stop words, don't bother making a request to the database
if (!lexemes[0].phraseto_tsquery) { if (!lexeme.phraseto_tsquery) {
return new Set(); return new Set();
} }