- I have a node (type “Post”).
- That node is connected to many images.
- Each image can have comments.
- Each comment can be connected to one user.
I need to query for all images. Each image returned should not have a comment that is from the user with uid 0x1
.
Additionally, I am trying to achieve the results without using vars
?
Here is the query that I have come up with so far.
Query
{
query(func: uid("0x5")) {
uid
IsOwnedBy {
uid
username
}
hasImages @filter(has(hasComments)) {
uid
filename
hasComments {
uid
text
commentBy @filter(not uid("0x1")) {
uid
username
}
dgraph.type
}
created
dgraph.type
}
created
dgraph.type
}
}
If I add not
to @filter(not has(hasComments))
, then it shows me all the images that does not have any comments. But I want images with or without comments, just not images that have comments from user 0x1
.
If I have not
on the commentBy @filter(not uid("0x1")) {
filter, then I do not see the commentBy
edge, but I still see the images that have comments from that user.
Dgraph metadata
v23.1.0