-
Notifications
You must be signed in to change notification settings - Fork 91
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
Add option to use returnDocument
#41
Conversation
mongodb-queue.js
Outdated
@@ -266,3 +273,12 @@ Queue.prototype.done = function(callback) { | |||
callback(null, count) | |||
}) | |||
} | |||
|
|||
Queue.prototype._optionsWithNewDocument = function(query) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe renaming the function to getDefaultQueryOptions
might improve readability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not quite what this function does: it actually adds the "return a new document" flag (whatever that is) to the passed set of options.
If we had access to the spread operator you could do something like:
var options = {
// other options here
...self._returnNewDocument(),
}
...but we can't really do that without a transpiler I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could just call it _returnOriginal()
anyway. Probably just as meaningful with fewer words:
var options = self._returnNewDocument({
// other options
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I got a question, sorry for my ignorence, but why don't you just replace the flag and discard the previous/deprecated option?
If the usage is deprecated, just replace it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid making this a breaking change — it would break any clients who are using older versions of mongodb
.
The `mongodb` Node.js driver deprecated use of `returnOriginal` in favour of `returnDocument` in [v3.6][1]. This non-breaking change allows consumers to opt in to using the newer `returnDocument` by setting an option on construction ```js var queue = mongoDbQueue(db, 'queue', { returnDocument : true }) ``` [1]: mongodb/node-mongodb-native#2808
1a04099
to
44fb12c
Compare
Fixes #38
The
mongodb
Node.js driver deprecated use ofreturnOriginal
infavour of
returnDocument
in v3.6.This non-breaking change allows consumers to opt in to using the newer
returnDocument
by setting an option on construction