-
Notifications
You must be signed in to change notification settings - Fork 0
💥 Promisify and add mongodb@5 support
#6
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
Conversation
mongodb-queue.js
Outdated
| }) | ||
| }) | ||
| Queue.prototype.createIndexes = async function() { | ||
| var indexname = await this.col.createIndex({ deleted : 1, visible : 1 }) |
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.
Any reason we use var
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.
Mostly to stay consistent with what was there before, but maybe I can upgrade this too while we're here
mongodb-queue.js
Outdated
| Queue.prototype.createIndexes = async function() { | ||
| var indexname = await this.col.createIndex({ deleted : 1, visible : 1 }) | ||
| await this.col.createIndex({ack: 1}, {unique: true, sparse: true}) | ||
| await this.col.createIndex({deleted: 1}, {sparse: true}) |
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.
Shouldn't we have just
const [indexname] = await Promise.all([
this.col.createIndex({ deleted : 1, visible : 1 }),
this.col.createIndex({ack: 1}, {unique: true, sparse: true})
this.col.createIndex({deleted: 1}, {sparse: true})
])
mongodb-queue.js
Outdated
| // So: | ||
| // 1) add this message to the deadQueue | ||
| // 2) ack this message from the regular queue | ||
| // 3) call ourthis to return a new message (if exists) |
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.
ourself not ourthis
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.
Ha bad find and replace 😅
mongodb-queue.js
Outdated
| if (this.deadQueue) { | ||
| // check the tries | ||
| if (msg.tries > this.maxRetries) { |
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.
| if (this.deadQueue) { | |
| // check the tries | |
| if (msg.tries > this.maxRetries) { | |
| if (this.deadQueue && msg.tries > this.maxRetries) { |
[`mongodb@5`][1] drops support for callbacks, which breaks this library, which is all written with callbacks. This is a **BREAKING** change which drops callback support from this library as well, and fully embraces promises through `async`/`await` syntax in both the library code and test code. This allows us to support both `mongodb@4` and `mongodb@5`. [1]: https://github.com/mongodb/node-mongodb-native/releases/tag/v5.0.0
mongodb@5drops support for callbacks, which breaks this library, which is all written with callbacks.This is a BREAKING change which drops callback support from this library as well, and fully embraces promises through
async/awaitsyntax in both the library code and test code.This allows us to support both
mongodb@4andmongodb@5.