Sort by nulls

Is there a way to sort and not show nulls or empty strings? I added last: null, but it doesn't work :
this.prisma.toSource.findMany({
where,
take: takeCount,
skip: skipCount,
orderBy: [
{
[dto.orderBy.value]: {
sort: dto.orderBy.direction,
nulls: 'last'
}
},
{ TITLE: { sort: 'asc', nulls: 'last' } },
{ ID_CONCURRENT: { sort: 'asc', nulls: 'last' } }
]
}),
this.prisma.toSource.findMany({
where,
take: takeCount,
skip: skipCount,
orderBy: [
{
[dto.orderBy.value]: {
sort: dto.orderBy.direction,
nulls: 'last'
}
},
{ TITLE: { sort: 'asc', nulls: 'last' } },
{ ID_CONCURRENT: { sort: 'asc', nulls: 'last' } }
]
}),
1 Reply
moosthuizen
moosthuizen5mo ago
@Guillaume630 If I understand what you mean correctly, maybe you are looking for extra conditions to add to the where clause? eg.
where: {
AND: [
{ TITLE: { not: null }},
{ TITLE: { not: "" }},
{ ID_CONCURRENT: { not: null }},
{ ID_CONCURRENT: { not: "" }},
// etc...
...where // Spread the existing where conditions
]
}
where: {
AND: [
{ TITLE: { not: null }},
{ TITLE: { not: "" }},
{ ID_CONCURRENT: { not: null }},
{ ID_CONCURRENT: { not: "" }},
// etc...
...where // Spread the existing where conditions
]
}
Want results from more Discord servers?
Add your server