I plan to generate a unique id to replace uid based on twitter’s snowflake algorithm. And all nodes are associated according to id, not uid.
please help me.
I plan to generate a unique id to replace uid based on twitter’s snowflake algorithm. And all nodes are associated according to id, not uid.
please help me.
You can’t replace uids
because that is internally used by dgraph for processing. You can look into assigning xids
to each node based on your algorithm.
@Anurag
Oh,so sad. If I give up dgraph in the future, maybe this is one of the reasons…
How to associate between xid?
xid
can be treated like just another predicate. From the docs here
<0x123> <xid> "http://schema.org/Person" .
Yeah. I know, I mean is it possible to create edge by xid instead of uid ?
Not directly but you can search for nodes with some xid
, save uid
of those nodes in a variable and then create edges using that variable. See section: External IDs and Upsert Block in the docs.
upsert {
query {
var(func: eq(SOME_XID, "Robin Wright")) {
Person as uid
}
}
mutation {
set {
uid(Person) <xid> SomeXID .
uid(Person) <edge1> something something .
uid(Person) <edge2> something something .
uid(Person) <dgraph.type> SomeType .
}
}
}