Auto-generate 128-bit UUID field (UUIDv4)?

Many databases have the ability to auto-generate a 128-bit UUIDv4.

I have a requirement to do this in my application as well. Can I do this in dgraph, or do I need to opt for another data store for this use case?

I see several posts about this on Github, etc. but no clear answer on whether a UUIDv4 (1) can be auto-generated by dgraph itself and (2) can be stored as exactly 128 bits.

Thanks in advance.

@MichelDiz answered this once in another Topic.

Refer: How can I build xidmap - #9 by MichelDiz.


In general Dgraph does not use XID, only UIDs. Internally Dgraph handles this, but it is not open for users manipulation.

If you have URI, URL, UUID, GUID, BIC, UDID, SSID, NPI, shortuuid, Snowflake, MongoID and etc. You must use this approach here .


@abhijit-kar So it sounds like the answers to my questions are:

(1) Can a UUIDv4 be auto-generated by dgraph itself?


(2) Can a UUIDv4 be stored as exactly 128 bits in dgraph?

No. Alternatively, a (heavier) string representation of a UUID can be stored as a xid instead.

Am I getting that right?