Can I delete a node with delete{ S * * .}

I have trouble when I try to delete a node using delete{ S * * .}

	delete { 
                <0x6> * * .

When I run the commond above in Ratel, it returns “Message:Done”
But I can still get all property the node using this uid.

and here’s my dgraph.type of <0x6>

type <人>{
    <ex_id>: String
    <身份证号>: String
    <ex_id>: String
    <性别>: String
    <地址>: String

The sample has the
_:node <dgraph.type> "人" . ?

I checked the schema and data Type, problem solved, thank you again!
but if the node have many predicates, do I have to define all of the predicates in its Type so I can delete or expand the node ?
What should I do if I dont know what kind of predicate a node would have ?
And how can I get all the edge or predicate a node was connected if I don’t have the TYPE?


Well, whoever is responsible for database administration has to define these things.

There’s a new feature now, which I’m not sure could be useful. That is “expand(myDefinedType)”. Maybe it could be used to a sort of debug the node and know which type it belongs to. But I don’t know yet if it would be useful for that.

As I said, Admin needs to define Types. You can find out what types there are by going to the “Schema” panel in Ratel UI. And every mutation you make must contain <dgraph.type>. Otherwise, it won’t work.

Also, if you need a “quick migration”. You can use the Upsert Block.

upsert {
  query {
    v as var(func: has(username)) #Make sure this predicate is used only by "Persons"

  mutation {
  # Adding the dgraph.type based in the given Predicate.
    set {
       uid(v) <dgraph.type> "Person" .


You can also do combinations in the query to do precise upserts.


1 Like

According to the tour, you should be able to delete all triples for a node with something like this:

delete {
  <0x123> * * .

Is this something that was changed in more recent versions of Dgraph? I’m on v20.03.1.

For what it’s worth the node I’m trying to remove doesn’t have a type (it’s just a basic list with no index, e.g. xyz [uid] .) I can successfully delete nodes if I specify the predicate (<0x123> <xyz> * .).

No, you can combine bulk delete with “bulk migration” in upsert block.

I may need to open a different topic for this as it is distinct from the case here (where there was a type). I was basing my question on the title more than the context.

1 Like