Snkz/mongoose-rollback

Can't store delta in _hist collection

Opened this issue · 2 comments

Currently delta data were stored in data like this

/* 1 */
{
    "_id" : ObjectId("587a3354a185ba2f002f75df"),
    "currentVersion" : 1,
    "data" : [ 
        {
            "createdAt" : ISODate("2017-01-14T14:19:00.815Z"),
            "_id" : ObjectId("587a3354a185ba2f002f75df"),
            "_version" : 0,
            "data" : "World",
            "name" : "Hello"
        }, 
        {
            "createdAt" : ISODate("2017-01-14T14:19:00.815Z"),
            "_id" : ObjectId("587a3354a185ba2f002f75df"),
            "_version" : 1,
            "data" : "Yo",
            "name" : "Hey",
            "__v" : 0
        }
    ],
    "__v" : 0
}

Is it possible to only store changed delta data here, this jsondiffpatch may help you.

Snkz commented

I picked storing a clone vs the diff to save on performance at the cost of storage. It also simplified the implementation greatly. Can you tell me what the use case for partial diffs is?

By saving diffs we can save storage space