How to version edges between nodes

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