Hi
Dgraph now supports transactions! So all of the above can now be done using them.
If you want to assert a unique index, you would:
- Create a transaction (this is done locally) by the client
- Send a query (via the transaction) to check if the predicate value already exists
- If it does, abort. If it doesn’t send a mutation to add the key as part of the transaction.
- Commit the transaction. Dgraph will abort if the query/mutation is no longer valid.
You can find out how to create a transaction for your given client on the client docs.
EDIT: you can read more about transactions here: Releasing distributed transactions in v0.9 - Dgraph Blog