Skip to content
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

Replace deprecated collection methods in mongodb-backend.js. Fixes #270 #271

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bazconz
Copy link

@bazconz bazconz commented Oct 6, 2018

Converts the deprecated collection methods and write concern setting to align with v2.0 and v3.1 of the MongoDB Driver APIs.

@@ -125,7 +125,7 @@ MongoDBBackend.prototype = {
values.forEach(function(value){doc[value]=true;});

// update document
collection.update(updateParams,{$set:doc},{safe:true,upsert:true},function(err){
collection.updateOne(updateParams, {$set:doc}, {w:1, upsert:true}, function(err){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this update call is intended for only one document and not for many documents?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just use update instead of updateOne?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update() is deprecated. I strictly followed the advice in https://mongoosejs.com/docs/deprecations.html to resolve the deprecation warnings and to not change the intended functionality. I used updateOne() because, in this case, update() is only updating the first document found.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a legit change.
But, don't we need to update mongodb version driver in order to use these new functions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants