Hi again. Trying to get all posts, not owned by cu...
# prisma-whats-new
m
Hi again. Trying to get all posts, not owned by current user. I have specific user id and do:
filter({ user: { id_not: "qwerty123" } })
but it returns me empty array, what I do wrong?
1
i
What’s your schema look like?
m
@iamclaytonray
Copy code
type Post @model {
  user: User @relation(name: "PostOnUser")
  ...
}
i
Do you have a field called
id_not
?
m
no
i
Cool. You can’t filter on fields you don’t have
That sounds like something you want to throw some business logic into instead of just a filter
a
Yes, you can. id_not is a generated filter field
just like all other filter fields generated (not_in, contains, starts_with etc.)
Only this seems to be a bug
I can reproduce that too
i
Really?
Oh, yeah, duh
a
Ah, it filters for null values
m
@agartha thank you for answer, If it is a bug, should I create the issue, etc, to find if it fixed?
i
If he had a default value, would it work?
Of a string
a
Can you confirm that the other Posts actually have a user?
m
no they not, just null
for test
a
If I do
allTests(filter: { user: { id_not: "x" }}){ id }
it works if the Test node has a User
it is not returned when user is null
m
looks like I have to use OR for it or it's just a bug?
a
filter:{ OR: [{ user: { id_not: "x" }}, { user: null }]}
Well, because user is null, it can't check the id value
So although it's not a bug, it is counterintuitive
m
@agartha thank you dude 👍
😎 1
a
Bool math at play, if ball = null, ball.color != 'blue' cannot be executed