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

Did you find this page helpful?