We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
In mongo version 6, they have made breaking changes to findOneAndUpdate (https://github.com/mongodb/node-mongodb-native/blob/main/etc/notes/CHANGES_6.0.0.md#findoneandx-family-of-methods-will-now-return-only-the-found-document-or-null-by-default-includeresultmetadata-is-false-by-default).
findOneAndUpdate
Now, it simply returns the document without any metadata, so in the following res.value will be undefined, it simply needs to return res.
res.value
res
Also, returnOriginal has been removed and should be replaced with returnDocument: 'before'
returnOriginal
returnDocument: 'before'
protected async lockNext() { const sleepUntil = moment().add(this.config.lockDuration, 'milliseconds').toDate(); const currentDate = moment().toDate(); const res = await this.getCollection().findOneAndUpdate({ $and: [ { [this.config.sleepUntilFieldPath]: { $exists: true, $ne: null }}, { [this.config.sleepUntilFieldPath]: { $not: { $gt: currentDate } } }, this.config.condition, ].filter((c) => !!c), }, { $set: { [this.config.sleepUntilFieldPath]: sleepUntil }, }, { returnOriginal: true, // return original document to calculate next start based on the original value }); return res.value; }
If you could please update this so we can upgrade to mongo 6 that would be appreciated! Thanks.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
In mongo version 6, they have made breaking changes to
findOneAndUpdate
(https://github.com/mongodb/node-mongodb-native/blob/main/etc/notes/CHANGES_6.0.0.md#findoneandx-family-of-methods-will-now-return-only-the-found-document-or-null-by-default-includeresultmetadata-is-false-by-default).Now, it simply returns the document without any metadata, so in the following
res.value
will be undefined, it simply needs to returnres
.Also,
returnOriginal
has been removed and should be replaced withreturnDocument: 'before'
If you could please update this so we can upgrade to mongo 6 that would be appreciated! Thanks.
The text was updated successfully, but these errors were encountered: