I have been trying to delete a node but nothing seems to be working

I am trying to delete a node but nothing seems to be working. I have this code as shown in the image.
image
I also tried the RDF format.
When I run it, it shows the success message but when I go to query then I see the node right there.

Somebody please tell me what I’m doing incorrectly.

1 Like

Hi @pbenipal61, This blog might be useful to you in fully understanding how the deletion of the nodes work.

Are you committing the mutation? I just learned this too…

1 Like

I ran that mutation in Ratel UI. Do i still need to commit the mutation somehow ?

Can you share the query that you are running for which you can still see the response? What response do you get and what is your expected response?

@pbenipal61, I wonder that you have not defined type in your schema. Delete (that only specifies UID) will only work if you have type defined in your schema and the nodes that you are deleting have corresponding <dgraph.type> predicate.

2 Likes

I have the same problem. Can’t delete nodes with (in Ratel UI):

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

I’m getting done message but nothing happens.

Json response:

{
  "data": {
    "code": "Success",
    "message": "Done",
    "queries": null,
    "uids": {}
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 11075,
      "processing_ns": 47614360,
      "assign_timestamp_ns": 813401,
      "total_ns": 48548613
    },
    "txn": {
      "start_ts": 2560452,
      "commit_ts": 2560453,
      "preds": [
        "1-11171-dgraph.type"
      ],
      "hash": "51b3a33aa7620f0bc477dd60a4668a0260ab20654a25628c3f36d7ede6fbffa4"
    }
  }
}

I’m not sure if I have dgraph.type. I see something similar but I’m not sure if it’s it.
I think I deleted ddgraph.type by mistake. It’s possible to add that again?
Could someone from the team check it for me?

Run this query to see if you have a type set:

{
  n(func: uid(0x25409d089)) {
    uid
    dgraph.type
  }
}

Notice if everything is deleted off from a node doing this query will still return the uid unless that behavior was changed somewhere along the way (I mainly stay within the API realm).

Yes you can of course run a mutation and readd the dgraph.type if needed.

And a delete S * * method only deletes the predicated of the declared type.

Another thing that may seem strange from users converting to Dgraph which pertains to the note above is that a node with only a uid does not actually exist in the database. Data only exists as triples so there has to be at least one triple for that node to “exist”. This is different than most any other NoSQL or rdbms that you may be use to where a document/row still exists even if it only contains the id.

1 Like

I don’t have type set. It is best practice to set dgraph.type according to the types I have in schema when I’m adding new nodes (just set dgraph.type with the type name?)?

Thanks for help!

1 Like