1.1.1RC1: Upsert block without node creation


I’m trying the last version and I’d like to use an upsert block including a query and a set mutation, but I don’t want to create a new node if my UID function returns nothing.

Here is an example where I want the People (uid=0x6666) to be friend with any People older than 60:


  old_people as me(func: gt(age, 60)) {


  "uid": 0x6666,
  "friend": { "uid": "uid(old_people)" }

The problem is if there is no such old people, dGraph will create an empty node.
Is it possible to disable this behavior, so a set on an empty UID variable does nothing?

You can use the Conditional Upsert https://docs.dgraph.io/mutations/#conditional-upsert

Thank you michel, I was so focused on basic upsert blocks I didn’t exploited the next doc section… It works fine now :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.