Context: I have a Post Mongoose model that contains a csv_files array field to store csv strings. I make a fetch API
just to comment here what my problem apparently was.
Error Message:
message: 'No matching document found for id "5c86d3a15bbcb965d85d80d1" version 3', name: 'VersionError', version: 3
My code:
update: function (data) {
var session = new Session(data);
database.logging("INFO", "session-update", session.cid, session.order.orderNumber);
return new Promise(function (resolve, reject) {
session.save()
.then(savedSession => resolve(savedSession))
.catch(savedSessionError => reject(savedSessionError))
});
}
My parameter 'data' was already a Mongoose object and I was creating a new one and trying to save() it. So like @dacopenhagen said, save() checks the version of the document and it's throwing an VersionError error.
How I fixed it Just removing the creation of the Session() object. Removed this line
var session = new Session(data);
I hope this help.