# Updating Data

**URL:** <https://discuss.dgraph.io/t/updating-data/8131>\
**Category:** Dgraph Clients\
**Tags:** untagged, dgraph-js\
**Created:** [December 28, 2017, 4:37pm UTC](https://discuss.dgraph.io/t/updating-data/8131 "2017-12-28T16:37:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [December 28, 2017, 4:37pm UTC](https://discuss.dgraph.io/t/updating-data/8131/1 "2017-12-28T16:37:18Z")

</div>

**Moved from GitHub [dgraph-js/9](https://github.com/dgraph-io/dgraph-js/issues/9)**

_Posted by_ [JohannesHoffmann](https://github.com/JohannesHoffmann):

i haven’t found any way to update data via mutation. With Ratel it looks like this:

```auto
{
    set {
        <0xf9078> <password> "xyz" .
     }
 }

```

How to implement this with dgraph-js and json? Is there some documentation i haven’t found?

Cheers

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [December 28, 2017, 5:51pm UTC](https://discuss.dgraph.io/t/updating-data/8131/2 "2017-12-28T17:51:08Z")

</div>

[MichelDiz](https://github.com/MichelDiz) _commented_ :

in [dgraph-js/examples/simple at master · dgraph-io/dgraph-js · GitHub](https://github.com/dgraph-io/dgraph-js/tree/master/examples/simple) you can find simple examples how to do it.

There’s no func for “Update”. You have to do a mutation using the same uid from the node created previously and the same predicate. Just overwrite it.

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [December 28, 2017, 6:22pm UTC](https://discuss.dgraph.io/t/updating-data/8131/3 "2017-12-28T18:22:57Z")

</div>

[JohannesHoffmann](https://github.com/JohannesHoffmann) _commented_ :

Yes, but the question is how to use the same uid in the right way?  
Is a js object like:

```auto
const p = {
    "0xf9078": {
        password: "xyz"
     }
}

```

but this one does not work.  
In the examples is only explained how to create new data and not how to override data with the uid and the same predicate.

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [December 28, 2017, 8:34pm UTC](https://discuss.dgraph.io/t/updating-data/8131/4 "2017-12-28T20:34:24Z")

</div>

[janardhan1993](https://github.com/janardhan1993) _commented_ :

you can do

```auto
{
"uid" : "0xf9078",
"password": "xyz"
}

```

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [December 28, 2017, 8:49pm UTC](https://discuss.dgraph.io/t/updating-data/8131/5 "2017-12-28T20:49:24Z")

</div>

[MichelDiz](https://github.com/MichelDiz) _commented_ :

This way you’re doing is a miss concept of how mutations work. The client will recognize the object you’re sending (the update as overwrite) if you write how Janardhan did. So You don’t need to send an object like u did. It’s seems logical, but not how mutations works.

Dgraph do not store data as Json. It’s translate it into triples stores (nquad store - [RDF 1.1 N-Quads](https://www.w3.org/TR/n-quads/) ) and vice versa. You have to always think in RFD model to deal with Dgraph.

```auto
const p = {
          "uid" : "0xf9078",
          "password": "xyz"
}

```

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [December 28, 2017, 10:35pm UTC](https://discuss.dgraph.io/t/updating-data/8131/6 "2017-12-28T22:35:48Z")

</div>

[manishrjain](https://github.com/manishrjain) _commented_ :

With this representation, our aim is to make the interaction work like documents. You can pass in the properties, along with the id of the document, and Dgraph would internally do what it needs to store them. Querying works the same way.

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [December 31, 2017, 8:30am UTC](https://discuss.dgraph.io/t/updating-data/8131/7 "2017-12-31T08:30:26Z")

</div>

[JohannesHoffmann](https://github.com/JohannesHoffmann) _commented_ :

Thank you all it is working well. This was not clear for me because i tried to mutete a override like the documentation of dgraph and not like a document. Maybe it would be nice to include an update mutation into the example to avoid this kind of questions?

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [July 11, 2020, 4:09am UTC](https://discuss.dgraph.io/t/updating-data/8131/8 "2020-07-11T04:09:58Z")

</div>


