Coffee11
Coffee1111mo ago

"in" filter keyword

How to achieve this in convex?
SELECT
employee_id,
first_name,
last_name,
department,
salary,
hire_date
FROM
employees
WHERE
employee_id IN (101, 102, 105);
SELECT
employee_id,
first_name,
last_name,
department,
salary,
hire_date
FROM
employees
WHERE
employee_id IN (101, 102, 105);
7 Replies
lee
lee11mo ago
In this sql example, is there an index on employee_id?
Coffee11
Coffee11OP11mo ago
yes will be querying _id
lee
lee11mo ago
If so, the equivalent in convex would be await Promise.all(ids.map((id)=>ctx.db.get(id)))
Coffee11
Coffee11OP11mo ago
thank you @lee
erquhart
erquhart11mo ago
fyi, had to coach it a bit on style, but the docs ai chat converted this sql into a complete convex query really well
Coffee11
Coffee11OP11mo ago
ai chat in convex website?
erquhart
erquhart11mo ago
Yep, kapa may work just as well too Could be handy if you already think in sql

Did you find this page helpful?