Coffee11
Coffee117mo 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
lee7mo ago
In this sql example, is there an index on employee_id?
Coffee11
Coffee11OP7mo ago
yes will be querying _id
lee
lee7mo ago
If so, the equivalent in convex would be await Promise.all(ids.map((id)=>ctx.db.get(id)))
Coffee11
Coffee11OP7mo ago
thank you @lee
erquhart
erquhart7mo 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
Coffee11OP7mo ago
ai chat in convex website?
erquhart
erquhart7mo ago
Yep, kapa may work just as well too Could be handy if you already think in sql

Did you find this page helpful?