# How to drop mutations

**URL:** <https://discuss.dgraph.io/t/how-to-drop-mutations/2815>\
**Category:** Dgraph\
**Created:** [June 28, 2018, 4:11am UTC](https://discuss.dgraph.io/t/how-to-drop-mutations/2815 "2018-06-28T04:11:29Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akshay-15mca1098](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@Akshay-15mca1098](https://discuss.dgraph.io/u/Akshay-15mca1098)\
**Post date:** [June 28, 2018, 4:11am UTC](https://discuss.dgraph.io/t/how-to-drop-mutations/2815/1 "2018-06-28T04:11:29Z")

</div>

Hi,  
Totally straight forward question. Want to drop all the mutations present in the graph. what I found on the `dgraph tour` that we can drop data by `id` but can we drop database by its name or drop all the mutation.

Thank you

---

<div class="post-metadata">

**Author:** ![shanghai-Jerry](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/shanghai-jerry/32/863_2.png) [@shanghai-Jerry](https://discuss.dgraph.io/u/shanghai-Jerry)\
**Post date:** [June 28, 2018, 4:59am UTC](https://discuss.dgraph.io/t/how-to-drop-mutations/2815/2 "2018-06-28T04:59:43Z")

</div>

DELETE ALL DATA: [https://docs.dgraph.io/deploy/#delete-database](https://docs.dgraph.io/deploy/#delete-database)

---

<div class="post-metadata">

**Author:** ![karan28aug](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@karan28aug](https://discuss.dgraph.io/u/karan28aug)\
**Post date:** [June 28, 2018, 5:14am UTC](https://discuss.dgraph.io/t/how-to-drop-mutations/2815/3 "2018-06-28T05:14:55Z")

</div>

To drop all data, you can use :

```auto
{
  "drop_all": true
}

```

It deletes everything from the database and starts from a clean state.

---

<div class="post-metadata">

**Author:** ![Akshay-15mca1098](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@Akshay-15mca1098](https://discuss.dgraph.io/u/Akshay-15mca1098)\
**Post date:** [June 28, 2018, 5:42am UTC](https://discuss.dgraph.io/t/how-to-drop-mutations/2815/4 "2018-06-28T05:42:53Z")

</div>

Hi @karan28aug  
tried with this but getting an error `Expected Left round brackets. Got: lex.Item [14] ":"`

---

<div class="post-metadata">

**Author:** ![karan28aug](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@karan28aug](https://discuss.dgraph.io/u/karan28aug)\
**Post date:** [June 28, 2018, 5:51am UTC](https://discuss.dgraph.io/t/how-to-drop-mutations/2815/5 "2018-06-28T05:51:41Z")

</div>

I tried this again it is working without an error.  
Just try it again in Alter in Ratel and let me know if it works for you or again showing you the same error.

---

<div class="post-metadata">

**Author:** ![shanghai-Jerry](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/shanghai-jerry/32/863_2.png) [@shanghai-Jerry](https://discuss.dgraph.io/u/shanghai-Jerry)\
**Post date:** [June 28, 2018, 5:52am UTC](https://discuss.dgraph.io/t/how-to-drop-mutations/2815/6 "2018-06-28T05:52:48Z")

</div>

you should run this operation in alter not in query or others like mutate, schema.

curl -X POST localhost:8080/ **alter** -d ‘{“drop\_all”: true}’

---

<div class="post-metadata">

**Author:** ![Akshay-15mca1098](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@Akshay-15mca1098](https://discuss.dgraph.io/u/Akshay-15mca1098)\
**Post date:** [June 28, 2018, 5:59am UTC](https://discuss.dgraph.io/t/how-to-drop-mutations/2815/7 "2018-06-28T05:59:03Z")

</div>

can you tell one more thing

how can i fetch whole data with one query withput using any id

**sample** - In sql we use \* from fetching all the data

---

<div class="post-metadata">

**Author:** ![karan28aug](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@karan28aug](https://discuss.dgraph.io/u/karan28aug)\
**Post date:** [June 28, 2018, 6:00am UTC](https://discuss.dgraph.io/t/how-to-drop-mutations/2815/8 "2018-06-28T06:00:47Z")

</div>

```auto
{
  all_nodes(func: has(_predicate_)) {
    expand(_all_) {
      expand(_all_) 
    }
  }
}

```

Try to use this and let me know if it works for you 🙂

---

<div class="post-metadata">

**Author:** ![Akshay-15mca1098](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@Akshay-15mca1098](https://discuss.dgraph.io/u/Akshay-15mca1098)\
**Post date:** [June 28, 2018, 6:04am UTC](https://discuss.dgraph.io/t/how-to-drop-mutations/2815/9 "2018-06-28T06:04:02Z")

</div>

yaa ts working

Is there anything like `nodetype` in dgraph or if its there how will i know.

thank you

---

<div class="post-metadata">

**Author:** ![karan28aug](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@karan28aug](https://discuss.dgraph.io/u/karan28aug)\
**Post date:** [June 28, 2018, 6:12am UTC](https://discuss.dgraph.io/t/how-to-drop-mutations/2815/10 "2018-06-28T06:12:20Z")

</div>

You can set a type to the Node when you are setting a schema for the data to be loaded.  
For ex:

```auto
name: string @index(term) @lang .
age: int @index(int) .
friend: uid @count .

```

Here string, int, uid are type you have assigned to name, age and friend…

---

<div class="post-metadata">

**Author:** ![Akshay-15mca1098](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@Akshay-15mca1098](https://discuss.dgraph.io/u/Akshay-15mca1098)\
**Post date:** [June 28, 2018, 6:56am UTC](https://discuss.dgraph.io/t/how-to-drop-mutations/2815/11 "2018-06-28T06:56:13Z")

</div>

I think you miss understood something, let me clear more  
actually, i played with NEO4J sometimes back, in NEO4J we have to make a `nodetype` first to insert data.

**NEO4J query** : `CREATE (n:People{name:"abc", age:35})`

People is a `nodetype`

Similarly, how can i create nodetype in dgraph 🙂

---

<div class="post-metadata">

**Author:** ![srinathganesh](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/srinathganesh/32/896_2.png) [@srinathganesh](https://discuss.dgraph.io/u/srinathganesh)\
**Post date:** [June 28, 2018, 8:06am UTC](https://discuss.dgraph.io/t/how-to-drop-mutations/2815/12 "2018-06-28T08:06:53Z")

</div>

> [@Akshay-15mca1098](#):
>
> Is there anything like nodetype in dgraph or if its there how will i know.

Ref: [howto](https://docs.dgraph.io/howto/)

```auto

import pydgraph
import json

client_stub = pydgraph.DgraphClientStub('localhost:9080')
client = pydgraph.DgraphClient(client_stub)

# Create Schema
schema = """type: string @index(exact) .
            name: string ."""
op = pydgraph.Operation(schema=schema)
client.alter(op)

# Data
txn = client.txn()
p = {
    "type": "People",
    "name": "Alpha",
}
assigned = txn.mutate(set_obj=p)

q = {
    "type": "People",
    "name": "Beta",
}
assigned = txn.mutate(set_obj=q)
txn.commit()

# Fetch type people
# Fetch Data
query = """query all($a: string) {
    all(func: eq(type, $a)) {
        expand(_all_) {}
    }
}"""
variables = {'$a': 'People'}

# Print
res = client.query(query, variables=variables)
ppls = json.loads(res.json.decode('utf-8'))

for ppl in ppls["all"]:
    print(ppl)

```

I think its a hack to get node type, but it seems to wrok

---

<div class="post-metadata">

**Author:** ![Akshay-15mca1098](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@Akshay-15mca1098](https://discuss.dgraph.io/u/Akshay-15mca1098)\
**Post date:** [June 28, 2018, 8:34am UTC](https://discuss.dgraph.io/t/how-to-drop-mutations/2815/13 "2018-06-28T08:34:25Z")

</div>

👍 great  
can we explicitly declare `nodetype`.  
[something like this](http://discuss.hypermode.com/t/dgraph-schema-system/916)

---

<div class="post-metadata">

**Author:** ![srinathganesh](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/srinathganesh/32/896_2.png) [@srinathganesh](https://discuss.dgraph.io/u/srinathganesh)\
**Post date:** [June 28, 2018, 8:35am UTC](https://discuss.dgraph.io/t/how-to-drop-mutations/2815/14 "2018-06-28T08:35:28Z")

</div>

I have a similar post here [Have many `schema`s](http://discuss.hypermode.com/t/have-many-schema-s/2822)

---

<div class="post-metadata">

**Author:** ![karan28aug](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@karan28aug](https://discuss.dgraph.io/u/karan28aug)\
**Post date:** [June 28, 2018, 2:56pm UTC](https://discuss.dgraph.io/t/how-to-drop-mutations/2815/15 "2018-06-28T14:56:16Z")

</div>

```auto
type School struct {
    Name string `json:"name,omitempty"`
}

type Person struct {
    Uid string `json:"uid,omitempty"`
    Name string `json:"name,omitempty"`
    Age int `json:"age,omitempty"`
    Married bool `json:"married,omitempty"`
    Raw []byte `json:"raw_bytes,omitempty"`
    Friends []Person `json:"friend,omitempty"`
    School []School `json:"school,omitempty"`
}

```

You can do something like this.

---

<div class="post-metadata">

**Author:** ![shanghai-Jerry](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/shanghai-jerry/32/863_2.png) [@shanghai-Jerry](https://discuss.dgraph.io/u/shanghai-Jerry)\
**Post date:** [June 29, 2018, 3:15am UTC](https://discuss.dgraph.io/t/how-to-drop-mutations/2815/17 "2018-06-29T03:15:19Z")

</div>

[https://docs.dgraph.io/mutations/#json-mutation-format](https://docs.dgraph.io/mutations/#json-mutation-format)

---

<div class="post-metadata">

**Author:** ![Akshay-15mca1098](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@Akshay-15mca1098](https://discuss.dgraph.io/u/Akshay-15mca1098)\
**Post date:** [June 29, 2018, 10:31am UTC](https://discuss.dgraph.io/t/how-to-drop-mutations/2815/18 "2018-06-29T10:31:00Z")

</div>

> [@karan28aug](#):
>
> type School struct {  
> Name string `json:"name,omitempty"`  
> }
> 
> type Person struct {  
> Uid string `json:"uid,omitempty"`  
> Name string `json:"name,omitempty"`  
> Age int `json:"age,omitempty"`  
> Married bool `json:"married,omitempty"`  
> Raw byte `json:"raw_bytes,omitempty"`  
> Friends Person `json:"friend,omitempty"`  
> School School `json:"school,omitempty"`  
> }

Hi @karan28aug  
like below format, I am creating a schema in python. Can you tell me how may I use above schema in python.

```auto
    name: string @index(exact) .
    friend: uid @reverse .
    age: int .
    married: bool .
    loc: geo .
    dob: datetime .

```

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [July 1, 2018, 3:09pm UTC](https://discuss.dgraph.io/t/how-to-drop-mutations/2815/19 "2018-07-01T15:09:56Z")

</div>

> <https://github.com/dgraph-io/pydgraph/blob/4ee4dd8ccee0584c7d0119505d6f0ccd189eb940/examples/simple/simple.py#L23>
