https://dgraph.io/tour/schema/8/
shows some options for deleting
Now i'd like to delete all triple for nodes of a given type. I assume this is done by some kind of combination of a query that selects the nodes for the the given type and then a mutation for each of these nodes. I couldn't find an example for this in the tutorial.
Let's assume I'd like to delete all triples for nodes of the type Country.
I know how to select the uids for the nodes:
{
query(func: has(<dgraph.type>)) @filter(eq(<dgraph.type>, "Country")) {
uid
}
}
But how do i combine this with a mutation?
https://discuss.dgraph.io/t/how-to-bulk-delete-nodes-or-cascade-delete-nodes/7308
seems to ask for an "upsert"
How could the deletion of all triples for nodes with a given type be achieved?
the following upsert seems to work:
upsert {
query {
# get the uids of all Country nodes
countries as var (func: has(<dgraph.type>)) @filter(eq(<dgraph.type>, "Country")) {
uid
}
}
mutation {
delete {
uid(countries) * * .
}
}
}