Boo
02/25/2022, 1:38 AMtrue
first and then false
lastNurul
02/25/2022, 2:32 PMmodel Post {
id Int @id @default(autoincrement())
title String
content String?
published Boolean @default(false)
author User? @relation(fields: [authorId], references: [id])
authorId Int?
}
The following query would return records with true first and false last.
const posts = await prisma.post.findMany({
where: {},
orderBy: {
published: 'desc',
},
});
sort order desc
will return records fields having field value as true
, while order asc
will return records having field value as false
first.
Here is a reference to orderBy documentation.
Please let me know if you have any further queries.