K
Join ServerKysely
help
How to select from a function with parameters?
I understand that
I created a helper:
But, I'm not exactly sure how I can use that since
kysely
will not natively support stored procedures / functions, and was wondering if there's a pattern for this:select * from function_name(<parameters>)
I created a helper:
export function similaritySearch(
text: string,
model: string,
) {
return sql`similarity_search(${sql.lit(text)}, ${sql.lit(model)})`;
}
But, I'm not exactly sure how I can use that since
db.selectFrom()
expects a table name.https://kysely-org.github.io/kysely/interfaces/Sql.html
is this what you're looking for?
is this what you're looking for?
const result = await sql<Person[]>`select * from person`.execute(db)
Thanks. I think this might work:
export function similaritySearch(text: string, model: string) {
return sql<SimilaritySearchTable>`similarity_search(${sql.lit(text)}, ${sql.lit(model)})`;
}
await sql<SimilaritySearchRow[]>`SELECT * FROM ${similaritySearch(text, model)}`.execute(db);