Title
m

Maslov

10/19/2017, 5:53 PM
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

iamclaytonray

10/19/2017, 5:56 PM
What’s your schema look like?
m

Maslov

10/19/2017, 5:58 PM
@iamclaytonray
type Post @model {
  user: User @relation(name: "PostOnUser")
  ...
}
i

iamclaytonray

10/19/2017, 5:59 PM
Do you have a field called
id_not
?
m

Maslov

10/19/2017, 5:59 PM
no
i

iamclaytonray

10/19/2017, 6:01 PM
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

agartha

10/19/2017, 6:02 PM
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

iamclaytonray

10/19/2017, 6:03 PM
Really?
Oh, yeah, duh
a

agartha

10/19/2017, 6:04 PM
Ah, it filters for null values
m

Maslov

10/19/2017, 6:04 PM
@agartha thank you for answer, If it is a bug, should I create the issue, etc, to find if it fixed?
i

iamclaytonray

10/19/2017, 6:04 PM
If he had a default value, would it work?
Of a string
a

agartha

10/19/2017, 6:04 PM
Can you confirm that the other Posts actually have a user?
m

Maslov

10/19/2017, 6:05 PM
no they not, just null
for test
a

agartha

10/19/2017, 6:05 PM
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

Maslov

10/19/2017, 6:06 PM
looks like I have to use OR for it or it's just a bug?
a

agartha

10/19/2017, 6:06 PM
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

Maslov

10/19/2017, 6:07 PM
@agartha thank you dude 👍
😎 1
a

agartha

10/19/2017, 6:08 PM
Bool math at play, if ball = null, ball.color != 'blue' cannot be executed