pandalive
(pandalive)
1
I have the following schema:
type User {
name
verified
follows
posts
...
}
type Post {
user
content
favorites
...
}
name: string @index(hash) .
verified: bool .
follows: [uid] @reverse @count .
posts: [uid] @reverse @count .
user: uid .
content: string .
favorites: [uid] .
I have a user homepage, and I need to query the post associated with that user:
1,Posts of users I follow.
2,Posts liked by users I follow.
3,Posts by verified users (like twitter’s verified).
But I don’t know how to write this query. I hope this query will not affect performance.
Please give me some suggestions, thanks.
Anurag
(Anurag)
2
I think the following should work:
For 1.
User(func: eq(name, "YourName")) {
follows {
name
posts{
content
}
}
}
For 2. Where do you store like
property? Put a filter
there.
For 3.
User(func: eq(verified, True)) {
name
posts{
content
}
}
Thanks.
But this is not what I expected, I mean these conditions are aggregated in one query. This is somewhat similar to twitter’s user homepage.
Sorry, I missed this, I have added : favorites
Anurag
(Anurag)
5
You mean you want all such posts in one query, which satisfies either of the above conditions? You can do something like this:
var(func: eq(name, "YourName")) {
follows {
p1 as posts
}
}
var(func: eq(verified, True)){
p2 as posts
}
var(func: eq(name, "YourName")) {
follows {
p3 as favourite
}
}
User(uid(p1,p2,p3)){
user
content
}
Yeah. Great, this is what i want, thanks. 
Anurag
(Anurag)
7
Great! Mark it as solved, so that others can re-use this 