Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE]: Support for Selecting Users from Multiple IDs #2269

Closed
ArdiraFarizPasha opened this issue May 7, 2024 · 3 comments
Closed

[FEATURE]: Support for Selecting Users from Multiple IDs #2269

ArdiraFarizPasha opened this issue May 7, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@ArdiraFarizPasha
Copy link

Describe what you want

Hello,
I want to select a user from multiple IDs, but I can't find the select option for multiple IDs in the Drizzle documentation (https://orm.drizzle.team/docs/select). So, for example, if I want to request user data from IDs 10, 15, and 20, the return is going to be an array of 3 user data with IDs 10, 15, and 20. Is it possible to implement this feature, or am I missing something?

Thank you Drizzle Team

@ArdiraFarizPasha ArdiraFarizPasha added the enhancement New feature or request label May 7, 2024
@zackperdue
Copy link

db.select().from(table).where(inArray(table.column, [1, 2, 3, 4]));

@ArdiraFarizPasha
Copy link
Author

db.select().from(table).where(inArray(table.column, [1, 2, 3, 4]));

Dude, thank you so much! I've been struggling for like 3 days trying to solve this lol

@ArdiraFarizPasha
Copy link
Author

ArdiraFarizPasha commented May 14, 2024

db.select().from(table).where(inArray(table.column, [1, 2, 3, 4]));

For everyone wondering where "inArray" is coming from, it's from Drizzle.
You can import it like this:
import { inArray } from 'drizzle-orm';

And in my case, you can use it like this:
const Users = await db.select().from(users).where(inArray(users.id, [41, 42, 43]));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants