-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"update" and "findByIdAndUpdate" don't increment "__v" #1265
Comments
Versioning was implemented to mitigate the {$set: {dummy: [2]}, $inc: { __v: 1 }} |
I'm not completely clear: Is the intent that "update" should never increment "__v" ? For example this apparently does not increment __v either:
Not a big deal since this is a corner case, but I'd like to have clarity. |
looks like a bug. |
Hey,in my app.this issue is still stay.the mongoose version is 3.8.22. Dtree.update({"_id": id}, frontData, function(err){
if(err){
console.log('Error: updateDTree: DB failed to update due to ', err);
res.send({'success':false, 'err':err});
}else{
console.log('Info: updateDTree: DB updated successully dtree');
res.send({'success':true});
}
}); so i it and use .update({}, {, $inc: { __v: 1}}, callback) in my code.Thx for your help |
Hi @edwardstudy, can you clarify what you mean? I don't quite understand. Could you perhaps provide a standalone file or mocha test that reproduces your issue? |
The following example creates three documents and attempts to force the update of "__v" by altering the "dummy" array. It works in the first case with a "findOne/save" construct, but doesn't work for the atomic "update" and "findByIdAndUpdate" functions.
Since it is possible for find/save constructs to be interleaved with atomic updates, it seems that it the "update" functions should also increment "__v".
This came up in the context of: http://stackoverflow.com/questions/14079693/mongoose-findbyidandupdate-or-update-and-increment-how-to-increment-v An acceptable work around might be to allow "__v" to be incremented directly in an "update".
RESULT:
The text was updated successfully, but these errors were encountered: