Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bompus
Copy link
Contributor

@bompus bompus commented Sep 2, 2023

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 than 4.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 bumping mongodb in package.json to ^6.0 for some pretty decent driver performance improvements and bug fixes.

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.
@djakaitis
Copy link

Would love to see this get merged 🚀

@palmtown
Copy link

palmtown commented Oct 6, 2023

+1 - Just found this PR, includeResultMetadata: true resolves my problem. It would be great to get this merged.

@s-dupuis
Copy link

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.

@sebamarynissen
Copy link

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.

@sebamarynissen
Copy link

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.

@bompus
Copy link
Contributor Author

bompus commented Aug 29, 2024

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.

@thematan
Copy link

thematan commented Dec 9, 2024

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.

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 😭

@sebamarynissen
Copy link

Is it an option for you to use Node 22.12? It has --experimental-require-module unflagged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants