Hi there,
I have some data, imported in Dgraph like this:
{'uid': '_:jared',
'id': '8Nh2v',
'dgraph.type': 'person'
'follow': [
{'uid': '_:aaron',
'id': 'NBywU',
'dgraph.type': 'event'},
{'uid': '_:bill',
'id': 'm66LK',
'dgraph.type': 'person'}]},
{'uid': '_:aaron',
'id': 'NBywU',
'dgraph.type': 'person'
'follow': [
{'uid': '_:jared',
'id': '8Nh2v',
'dgraph.type': 'person'}]},
{'uid': '_:bill',
'id': 'm66LK',
'dgraph.type': 'person'
'follow': []}
What I want to achieve here is to get a list of all the "person"s who follow someone but the other “person” does not follow them back. For instance, in this example, the query should return _:jared and _:bill as a result since _:jared follows _:bill but _:bill follows no one.
So far what I’ve got is this:
1- First I get the uid of some “person” with a specific “id” which in this case, let’s assume is “0x15”:
{
getuid(func: eq(id, "8Nh2v")){
uid
}}
2- Then I query to see users who dont follow that like this:
{ users(func: eq(id, "8Nh2v"))
@recurse(depth:1000)
{
uid
id
dup @filter(not uid_in(dup, "0x15" ))
}
}
This does work but I believe it is not the efficient because I need to run 2 queries for each “person”.
I was wondering if there is a way to go through all data in the Dgraph filtering ‘dgraph.type’: ‘person’ and loop through each result and find all the "person"s that they follow but is not getting followed back. I hope I am doing things right here, but I’m new to Dgraph and want to explore it so all critics are welcome. Thank you