Home > Software engineering >  Can you build a query in prisma without executing it?
Can you build a query in prisma without executing it?

Time:07-09

I have a find method in my api that takes these parameters

-limit (optional)

-select (optional)

-sort (optional)

-skip (optional)

In MongoDB you can build a query like this :

let query = model.find(query);

if(limit) {
  query.limit(limit)
 }
 
 if(skip) {
  query.skip(skip)
 }
 
// ....

let result = await query.exec();

Is there a similar option in Prisma ?

CodePudding user response:

I am not Prisma user, but seems like you can build config parameters beforehand like

let query = {
    skip: skip,
    take: limit
};
prisma.model.findMany(query)
  • Related