Schema that links Events to Contacts:
type Contact {
id: ID
hasEvents: [Event] @hasInverse(field: at)
...
}
type Event {
id: ID
at: Contact @hasInverse(field: hasEvents)
...
}
I imported the data with:
{
set {
_:contact_1 <dgraph.type> "Contact" .
...
_:event_1 <dgraph.type> "Event" .
_:event_1 <Event.at> _:contact_1 .
...
}
}
As you see, I forgot to add the reverse of _:contact_1 <Contact.hasEvents> _:event_1 .
In my import script. Is there a way to fix this after the fact and somehow create the reverse for every Event.at
edge and map it to Contact.hasEvents
edge?
I was thinking of an upsert like:
upsert {
query {
event as var(func: has(Event.at)){
Event.at {
contact as uid
}
}
}
mutate {
set {
contact <Contact.hasEvent> event .
}
}
}
But this will set every event for every contact, and does not produce the desired results.
Is this possible without FOREACH func in DQL (loops in Bulk Upsert) VOTE! - #4 by MichelDiz