-
Notifications
You must be signed in to change notification settings - Fork 28
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
Support MongoDB driver 6.0 #46
base: main
Are you sure you want to change the base?
Conversation
driver 6.0 no longer includes metadata on findOneAndUpdate... calls, so it returns the document at the root, rather than having to reach into .value to get the document. This commit provides backwards compatibility by passing the option includeResultMetadata: true to retain the old behavior.
Would love to see this get merged 🚀 |
+1 - Just found this PR, includeResultMetadata: true resolves my problem. It would be great to get this merged. |
With MongoDB 5 end of life coming in less than a year (https://www.mongodb.com/support-policy/lifecycles), it should be considered to merge this PR. |
Welp, I didn't see this while working on #53. I had the same problem and used the same fix, but I've also used the opportunity to make mongodb 6 the default for agenda and added tests for all driver versions 4, 5 and 6. |
As I needed this too, I've decided to release my own fork @whisthub/agenda on npm, so if you're stuck on this, you can use that one. It makes mongodb a peer dependency, supporting version 4, 5 and 6 (and hopefully future versions without a problem too). Note that I've also made it esm only. I've also created a new PR (#55) to merge this back into this repo as well. |
Please see the PR ( #55 ) mentioned in #46 (comment) for what I believe is a better solution, that solves some additional issues that I hadn't noticed. |
ESM made it unusable. used dynamic import to bypass Jest inability to cope with it, but got stuck when bundling for production in webpack with externals included. you could have been my hero 😭 |
Is it an option for you to use Node 22.12? It has |
MongoDB driver 6.0 no longer includes metadata on
findOneAndUpdate...
calls, so it returns the document at the root, rather than having to reach into.value
to get the document.The new option / default is
includeResultMetadata: false
This commit provides backwards compatibility by passing the option
includeResultMetadata: true
to retain the old behavior.FYI - I pass my own 6.0.0 driver instance in with
new Agenda({ mongo: ... });
and I've noticed zero issues with using newer drivers than4.11.0
that this package is currently pinned to, and I've been using it for quite some time. I'd recommend testing yourself, then bumpingmongodb
in package.json to^6.0
for some pretty decent driver performance improvements and bug fixes.