Hi everyone, so I’m attempting to query a type and...
# orm-help
p
Hi everyone, so I’m attempting to query a type and I want all instances where a field of that type is null. Is there a proper way to do this? I can think of a solution, however I suspect that solution might create problems elsewhere.
r
hey @Philipp Rajah Moura Srivastava 👋 Is this regarding Prisma 1 or 2?
p
Prisma 1 😞 still waiting for mongodb support
sticking with you guys tho!
🙌 1
hey @Ryan is there an answer to my question tho?
r
For P1 let me check and get back to you
p
sweet thank you. I don’t expect that this query will return many objects so I could query all of them and then do some work on the server to get the data i want, but a query would be nice
Did you get around to checking yet? @Ryan
r
If it’s a field in the same relation, then it should be simple as doing this (for a user’s relation):
Copy code
prisma.users({ where: { age: null } })
p
I have an event with a school type subfield so i want something like prisma.events( { where: { otherecritearia, school: AND: [ null, users school] } } )
r
I don’t think that’s possible in Prisma 1, where you can use a compound condition inside a field query. I think two queries would be required here, one to get the users school and the other for nulls and combining the two.
p
ok thanks
and raw queries are not possible right?
r
If you're using Mongo, then you can directly use Mongoose for raw queries.
p
Is there an example somewhere for that? I haven’t been able to find anything
r
I don’t think there is, but let me still check.
p
Any update on this?
Tried to find resources but haven’t been able to
r
No I couldn’t find any. I think checking Mongoose docs would be the only option here.
p
Ok cool, do you know where the access point in the context is? I was going through it, trying various things but I couldn’t figure it out