Localhost:8080/alter -d '{"drop_op"

Hi again, and sorry to ask so many question :slight_smile:

From doc:
https://docs.dgraph.io/clients/#alter-the-database-1

$ curl -X POST localhost:8080/alter -d '{"drop_op": "TYPE", "drop_value": "Film"}'

Steps:

  1. If I do:
curl -X POST localhost:8080/alter -d 'name: string @index(term) .'
  1. And the add som data:
POST http://{{host}}/mutate?commitNow=true
Content-Type: application/json

{
    "set": [
    {
        "name": "Alice"
    },
    {
        "name": "Bob"
    }
    ]
}
  1. This do not delete data:
curl -X POST localhost:8080/alter -d '{"drop_op": "TYPE", "drop_value": "name"}'

Expected: Alice & Bob to be deleted?

1 Like

{"drop_op": "TYPE", "drop_value": "name"}

This operation is to delete Type, not entities.

You probably wanna use

$ curl -X POST localhost:8080/alter -d '{"drop_attr": "name"}'

This will drop the attribute.

Usually, we use the β€œDelete” operation for that.

Thanks @MichelDiz

Of course, you are totally right "{"drop_op": "TYPE", "drop_value": "name"}" do indeed remove Types.

I was actually looking for a way to delete data for a Type and or a Predicate, during development - it is nice to β€œrun some code and then delete the data again.”, not the schema or type, just the data.

I thought, maybe it was possible(drop_op word in common / reading doc to fast) as you can do it for the entire dgraph database with:
curl -X POST localhost:8080/alter -d '{"drop_op": "DATA"}'

For now I can just use graphql:

mutation deleteAuthorAll{
  deleteAuthor(filter:  { not: {ids: [""]}}){
    msg
  }
}

If you know of a better way, please let me know?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.