Skip to content

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.


// 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.

3 participants