# How to version edges between nodes

**URL:** <https://discuss.dgraph.io/t/how-to-version-edges-between-nodes/12015>\
**Category:** Dgraph\
**Tags:** kind:question\
**Created:** [December 21, 2020, 7:57pm UTC](https://discuss.dgraph.io/t/how-to-version-edges-between-nodes/12015 "2020-12-21T19:57:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinaypillai](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/vinaypillai/32/5766_2.png) [@vinaypillai](https://discuss.dgraph.io/u/vinaypillai)\
**Post date:** [December 21, 2020, 7:57pm UTC](https://discuss.dgraph.io/t/how-to-version-edges-between-nodes/12015/1 "2020-12-21T19:57:39Z")

</div>

Hi! Just had a quick question about implementing edge versioning between nodes. For instance, if customer A bought a product that relationship might look like:

```auto
{
    "name": "A",
    "bought":{
        "name":"product",
        "bought|timestamp":"90000000"
    }
}

```

However, if customer A were to buy the same product a week later, how would one best represent that relationship without overwriting the previous timestamp facet?

---

<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:** [December 21, 2020, 10:03pm UTC](https://discuss.dgraph.io/t/how-to-version-edges-between-nodes/12015/2 "2020-12-21T22:03:03Z")

</div>

I personally would do like this

```auto
[
   {
      "name": "Alfred",
      "purchases": [
         {
            "purchaseID": "E32F55D",
            "timestamp": "90000000",
            "createdAt": "12/21/2020",
            "bought": "true",
            "inTheCart": [
               {
                  "uid": "product_1"
               },
               {
                  "uid": "product_2"
               }
            ]
         },
         {
            "purchaseID": "E33N00G",
            "timestamp": "90000000",
            "createdAt": "02/03/2021",
            "bought": "true",
            "inTheCart": [
               {
                  "uid": "product_1"
               },
               {
                  "uid": "product_2"
               },
               {
                  "uid": "product_3"
               }
            ]
         }
      ]
   },
   {
      "name": "product 1",
      "price": "30",
      "dgraph.type": "Product"
   },
   {
      "name": "product 2",
      "price": "120",
      "dgraph.type": "Product"
   },
   {
      "name": "product 3",
      "price": "15",
      "dgraph.type": "Product"
   }
]

```

You can still use facets if you wanna do short queries. You would copy just the data you need in the inTheCart list, so you can query it without traversing.

With this schema model you would have a lot of information about your customer. Counting would be easy and also visualize it in Ratel would be nice.

Cheers.

---

<div class="post-metadata">

**Author:** ![vinaypillai](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/vinaypillai/32/5766_2.png) [@vinaypillai](https://discuss.dgraph.io/u/vinaypillai)\
**Post date:** [December 21, 2020, 10:48pm UTC](https://discuss.dgraph.io/t/how-to-version-edges-between-nodes/12015/3 "2020-12-21T22:48:46Z")

</div>

Thanks! I think that would a great way to structure this kind of data.
