Delete - Mutations

A delete mutation, signified with the delete keyword, removes triples from the store.

For example, if the store contained

<0xf11168064b01135b> <name> "Lewis Carrol"
<0xf11168064b01135b> <died> "1998"
<0xf11168064b01135b> <dgraph.type> "Person" .

Then delete mutation

{
  delete {
     <0xf11168064b01135b> <died> "1998" .
  }
}

Deletes the erroneous data and removes it from indexes if present.

For a particular node N, all data for predicate P (and corresponding indexing) is removed with the pattern S P *.

{
  delete {
     <0xf11168064b01135b> <author.of> * .
  }
}

The pattern S * * deletes all known edges out of a node (the node itself may remain as the target of edges), any reverse edges corresponding to the removed edges and any indexing for the removed data. The predicates to delete are derived from the type information for that node (the value of the dgraph.type edges on that node and their corresponding definitions in the schema). If that information is missing, this operation will be a no-op.

{
  delete {
     <0xf11168064b01135b> * * .
  }
}

Note The patterns * P O and * * O are not supported since its expensive to store/find all the incoming edges.

Deletion of non-list predicates

Deleting the value of a non-list predicate (i.e a 1-to-1 relation) can be done in two ways.

  1. Using the star notation mentioned in the last section.
  2. Setting the object to a specific value. If the value passed is not the current value, the mutation will succeed but will have no effect. If the value passed is the current value, the mutation will succeed and will delete the triple.

For language-tagged values, the following special syntax is supported:

{
  delete {
    <0x12345> <[email protected]> * .
  }
}

In this example, the value of name tagged with language tag es will be deleted. Other tagged values are left untouched.


This is a companion discussion topic for the original entry at https://dgraph.io/docs/mutations/delete/