Mongoose restore previous revision

Viewed 259

I increase the '__v'-property of my mongoose-schema using the mongoose-middleware

contractSchema.pre("findOneAndUpdate", function (next) {
  this.update({}, { $inc: { __v: 1 } }, next);
})

As i just realised this then overwrite the existing document and does not save it separatly. What I need is to save all previous versions of the table so i can get each previous version individually, is this possible using the middleware?

0 Answers
Related