Requires document
versioning in MongoDB
while editing on the app.
I have many "Cards" created by various users. A card can be edited at any point. The app must hold all the changes in the database so that an admin can roll back to old changes.
To do that I have tried to copy and existing document
which represents one card, reinsert it with a different _id
which will be considered version 0. Then update the copied one with latest changes. This was I expect db to hold version 1, 2, 3 of the same document
. I say same document because I am copying the first document's _id as "source_id" for later to accumulate the result.
Using MongoDB.Driver
with VB.Net
Although this hasn't worked, but is it a correct way to do?
Issues: FindOneAndUpdate
returns the updated document
and I lose the initial data.
Saw here about how to duplicate a document, but this didn't work for me. Saw many places mentioned upsert
, but the following didn't work for me either.
question from:
https://stackoverflow.com/questions/65890854/how-to-do-a-document-versioning-in-mongodb-using-driver 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…