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

Make empty array to return all the records when using in #234

Open
drac94 opened this issue Aug 23, 2022 · 0 comments
Open

Make empty array to return all the records when using in #234

drac94 opened this issue Aug 23, 2022 · 0 comments

Comments

@drac94
Copy link

drac94 commented Aug 23, 2022

Right now when passing an empty array when using in does not return anything, is there a way to make it return everything instead? this will help to use dynamic properties

Or maybe there is another way of doing it, sorry if thats the case

const idParam = req.url.searchParams.getAll('id');

db.employee.findMany({
  where: { id: { in: idParam } },
  take: size,
  skip: (page - 1) * size,
}),

Above code returns empty if idParam is null, undefined or an empty array []

Right now I'm doing this instead

const idParam = req.url.searchParams.getAll('id');

if(idParam.length > 0){
  db.employee.findMany({
    where: { id: { in: idParam } },
    take: size,
    skip: (page - 1) * size,
  }),
} else {
  db.employee.findMany({
    take: size,
    skip: (page - 1) * size,
  }),
}

Thanks!

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

No branches or pull requests

1 participant