[Query] Select with IN array operator


I’m trying to adapt some SQL query with IN operator, “SELECT * FROM user WHERE email IN (‘user1@email.com’, ‘user2@email.com’)”

With a simple user document:
{ "username": "afonsosilva91", "email": "afonso23@gmail.com" }

With my bucket full of users and I only want select around 20 by email. So, having an array with 20 emails it is a simple query with SQL statement, here I’m not getting there … I also tried made a loop with singular calls but I worried about performance and do it with one query.

Do you have some basic example about this?


A little cleaner than SQL.

FROM `user`
WHERE email IN [ 'user1@email.com', 'user2@email.com' ];

You should also have an index on email.

Thank tou @geraldss! I think I tried that query but somehow I failed. But yes I improved the query from 6s to 2s, just getting all at one time. :wink:

1 Like