Hey.. I want to get search results along with coun...
# prisma-client
o
Hey.. I want to get search results along with count of them.. is this the correct way to it ?
const usersWithCount = await prisma.$transaction([
            
prisma.user.count({
               
where: { username: { startsWith: keyword.toLowerCase() } },
            
}),
            
prisma.user.findMany({
               
where: {
                  
username: {
                     
startsWith: keyword.toLowerCase(),
                  
},
               
},
            
}),
         
])
         
return {
            
users: usersWithCount[1],
            
total: usersWithCount[0],
         
}
r
Yeah that is the way to do it for now until this is supported. It would be great if you could add a 👍 to the above request 🙂
o
Thanks a lot 🙂
👍 1