Dgraph DQL Tour

Schema

Deleting Data

There are three deletion options inside a delete mutation.

  • <uid> <edge> <uid>/"value" . Delete a single triple
  • <uid> <edge> * . Delete all triples for a given edge
  • <uid> * * . Delete all triples for a given node

The examples given here are not complete. Uids assigned on your instance would be unique. Try something out; you’re not going to hurt anyone, just delete their friends.

You can do the same example using JSON format. You’re able to do that through our clients, cURL or Ratel UI.

See in JSON:

Delete all triples for a given node

 {
    "delete": [
        {
            "uid": "0xa"
        }
    ]
}

Delete all triples for a given edge

 {
    "delete": [
        {
            "uid": "0xa",
            "friends": null
        }
    ]
}

This doesn’t delete their children which means in this case, it will not erase the “friends”. Only the relation would be deleted.

Deleting relations and then their children

 {
    "delete": [
        {
            "uid": "0x2", # Answer UID.
            "comment": {
                "uid": "0x3" # Delete relation (edge) with the Comment
        }
        },
        {
            "uid": "0x3" # Delete the actual comment
        }
    ]
}
Tip

The JSON example may end up helping you better understand the format in RDF.

3.8 Deleting Data