mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
refactor: kysely.selectNoFrom
This commit is contained in:
parent
f259ab8d88
commit
3c3f90eddb
1 changed files with 3 additions and 6 deletions
|
|
@ -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<Set<string>> {
|
||||
const { q, limit, offset } = opts;
|
||||
|
||||
const [lexeme] = await kysely.selectNoFrom(
|
||||
sql`phraseto_tsquery(${q})` as unknown as SelectExpression<DittoTables, never>,
|
||||
)
|
||||
.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();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue