jeudi 10 octobre 2019

Undo redo for a huge object

I have a requirement where the product needs to implement undo-redo functionality.

Currently I hold a huge Object which comes from a single mongo collection.

Pseudo structure:

{
  cart:{
    products:[
      {
        name: "Watch",
        quantity: 1,
        shippingDate: 123456782,
        text: "lorem ipsum....",
        prices:[
          {
            currency: "USD",
            price: 300
          },
          {
            currency: "GBP",
            price: 220
          }
        ]
      }
    ],
    ...someMoreKeyValuePair
  }
}

Now the update can happen on any node, eg: product getting added/modified/removed, cart level data getting added/modified/removed.

And the structure is huge, now how do I maintain undo-redo actions on any change happening on the entire structure.

What data-structure or design pattern should I read to get a better approach on solving this.

Aucun commentaire:

Enregistrer un commentaire