How to version edges between nodes

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:

{
    "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?

I personally would do like this

[
   {
      "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.

1 Like

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