Closed jqphu closed 1 year ago
Not sure if this is a me problem or if the filters from Prisma don't allow a method to do this but I'll check it out
Here's a snippet of something similar on typescript.
const users = await prisma.user.findMany({
where: {
NOT: [
{
referredBy: null,
}
],
AND: [
{
referredOneMonthTrialExpiryDate: null,
}
]
}
});
Finding all the users where the referredBy is not null, but the referredOneMonthTrialExpiryDate is null.
ReferredBy in this case is a relation, referredOneMonthTrialExpiryDate is just a simple DateTime.
Hope that's somewhat helpful.
I've thought about it, and I think I'll need to custom-implement this operation myself. The example you provided is basically user::referred_by::equals(None)
- but I don't provide an equals
function for relations, and I don't plan on it since it only makes sense for null relations.
Instead I'm thinking of adding an is_null
filter which does the same thing. It'd look like user::referred_by::is_null()
.
EDIT: Done in 36372407d5080363b2e700390e3458e1c27c0b89
That makes sense!
Thanks @Brendonovich :).
Following from discord.
Given an optional relation
It would be nice to filter on this field e.g. get all the users that don't have a profile.