# Dgo DeleteJson Mutation removes the dgraph.type but not the other fields

**URL:** <https://discuss.dgraph.io/t/dgo-deletejson-mutation-removes-the-dgraph-type-but-not-the-other-fields/14149>\
**Category:** Dgraph\
**Tags:** dgo\
**Created:** [May 13, 2021, 6:21pm UTC](https://discuss.dgraph.io/t/dgo-deletejson-mutation-removes-the-dgraph-type-but-not-the-other-fields/14149 "2021-05-13T18:21:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Baggerone](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/baggerone/32/8180_2.png) [@Baggerone](https://discuss.dgraph.io/u/Baggerone)\
**Post date:** [May 13, 2021, 6:21pm UTC](https://discuss.dgraph.io/t/dgo-deletejson-mutation-removes-the-dgraph-type-but-not-the-other-fields/14149/1 "2021-05-13T18:21:56Z")

</div>

I’ve copied and tweaked the portion of the dgo examples\_test.go file that relates to using a DeleteJson mutation.

It seems to only delete the dgraph.type of the deleted instance and not the other fields (e.g. `uid`, `name`, `age`).

I have …

```auto
	type Person struct {
		Uid string `json:"uid,omitempty"`
		Name string `json:"name,omitempty"`
		Age int `json:"age,omitempty"`
		DType []string `json:"dgraph.type"`
	}

	ap := Person{
		Name: "Alice",
		Age: 21,
		DType: []string{"Person"},
	}

```

and

```auto

	d := map[string]string{"uid": <the actual uid>}
	pb, err = json.Marshal(d)
	if err != nil {
		log.Fatal(err)
	}

	mu = &api.Mutation{
		CommitNow: true,
		DeleteJson: pb,
	}

	_, err = dg.NewTxn().Mutate(ctx, mu)
	if err != nil {
		log.Fatal(err)
	}

```

When I query for `eq(dgraph.type, "Person")`, the instance is not found, but when I query for `func: uid("<the actual uid>")`, the instance is found, including `name` and `age`.

---

<div class="post-metadata">

**Author:** ![kaustubh](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/kaustubh/32/8364_2.png) [@kaustubh](https://discuss.dgraph.io/u/kaustubh)\
**Post date:** [May 13, 2021, 6:53pm UTC](https://discuss.dgraph.io/t/dgo-deletejson-mutation-removes-the-dgraph-type-but-not-the-other-fields/14149/2 "2021-05-13T18:53:38Z")

</div>

Well, we have a problem here. Even though your `ap` object is of `struct Person`, the `pb` object is just a `[]byte` representation of the `d` map. The passed pb does not contain the dgraph.type value ( which it must definitely contain when calling deletion mutation for deleting the entire node). Use the `DeleteNquads` attribute instead if you just want to delete the entire node given only the uid

---

<div class="post-metadata">

**Author:** ![Baggerone](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/baggerone/32/8180_2.png) [@Baggerone](https://discuss.dgraph.io/u/Baggerone)\
**Post date:** [May 13, 2021, 8:09pm UTC](https://discuss.dgraph.io/t/dgo-deletejson-mutation-removes-the-dgraph-type-but-not-the-other-fields/14149/3 "2021-05-13T20:09:45Z")

</div>

The only way I see to make it works is by doing the following. Is that right?

```auto
	pb = []byte(fmt.Sprintf(`
<%s> <dgraph.type> * .
<%s> <name> * .
<%s> <age> * .
`, alice, alice, alice))
	fmt.Printf("\nFor deleting %s\n", pb)

	mu = &api.Mutation{
		CommitNow: true,
		DelNquads: pb,
	}

	_, err = dg.NewTxn().Mutate(ctx, mu)

```

---

<div class="post-metadata">

**Author:** ![kaustubh](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/kaustubh/32/8364_2.png) [@kaustubh](https://discuss.dgraph.io/u/kaustubh)\
**Post date:** [May 14, 2021, 10:29am UTC](https://discuss.dgraph.io/t/dgo-deletejson-mutation-removes-the-dgraph-type-but-not-the-other-fields/14149/4 "2021-05-14T10:29:21Z")

</div>

If you want to remove the entire thing just write the following →

```auto
pb = []byte(fmt.Sprintf(`<%s> * * .`, alice))

```

This in essence means delete the uid for any given predicate and any assigned value

---

<div class="post-metadata">

**Author:** ![Baggerone](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/baggerone/32/8180_2.png) [@Baggerone](https://discuss.dgraph.io/u/Baggerone)\
**Post date:** [May 14, 2021, 12:29pm UTC](https://discuss.dgraph.io/t/dgo-deletejson-mutation-removes-the-dgraph-type-but-not-the-other-fields/14149/5 "2021-05-14T12:29:35Z")

</div>

When I do it that way, the fields don’t get deleted. They’re still available with the original data.

Even if I do

```auto
 	pb = []byte(fmt.Sprintf(`
 <%s> <dgraph.type> * .
 <%s> * * .`, alice, alice))

```

it doesn’t delete the data
