KyselyK
Kysely3y ago
3 replies
Theo

How to select from a function with parameters?

I understand that 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.
Was this page helpful?