How can I delete the entire node according to the ID? I use the following command according to the document, but the node and the value below the node have not been deleted, and many materials have not been found on the Internet. Why? If I delete all the attributes under each node accurately, can I delete the entire node?
{
“Delete”: {
“uid”: “0x2724”
}
}
No matter how I delete this node, it still exists. My version is 1.1.1, but if I delete all the attributes, this node will disappear
Deleting all the edges (aka attributes) of a node means deleting the node. Dgraph doesn’t automatically delete any incoming edges to the node.
It looks like you’re using the syntax to delete a node via the JSON format on the HTTP API: https://docs.dgraph.io/mutations/#json-syntax-using-raw-http-or-ratel-ui. The syntax is a JSON object where "delete"
is a list:
{
"delete": [
{
"uid": "0x2724"
}
]
}
Note that the above is an S * *
which requires type information on the node.
You can also use S P *
deletion to delete specific predicates from a node.
In addition to what Dmai said, you need to have a well-defined Type Schema for operations like Delete to work.
Check this topic https://docs.dgraph.io/query-language/#type-system
Well, the last thing is the missing <dgraph.type> just like Can I delete a node with delete{ S * * .} - #2 by MichelDiz
Also, in the video I cannot see the Type Schema. Can you check that? you are showing just the predicate definitions.
Question:
Assuming a schema was not explicitly defined and as such, a type was not defined.
I then proceed to create a node.
How do we go about deleting such a node.
From some older version tutorial videos, it would seem “type” was introduced at a later point.
Can nodes be deleted if we created nodes without a type?
How to get rid of them in an existing graph DB?
Thanks.
Yes.
You have to explicitly delete the whole “node”.
e.g
Consider this.
{
set {
_:alice <name> "Alice" .
_:alice <somepred> "test" .
_:alice <someOther> "su" .
_:alice <somepred2> "si" .
}
}
To delete this you gonna do like:
{
delete {
<0x12345> <name> * .
<0x12345> <somepred> * .
<0x12345> <someOther> * .
<0x12345> <somepred2> * .
}
}
Great thanks.
Why does the below not work?
{
delete {
<0x12345> * * .
}
}
The pattern S * *
need a well defined Type Schema.
Understood.
Thanks. Appreciate the quick responses.
Cheers.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.