Skip to content

Support MongoDB driver 6.0#46

Open
bompus wants to merge 3 commits into
hokify:mainfrom
bompus:support-mongodb-driver-6.0
Open

Support MongoDB driver 6.0#46
bompus wants to merge 3 commits into
hokify:mainfrom
bompus:support-mongodb-driver-6.0

Conversation

@bompus

@bompus bompus commented Sep 2, 2023

Copy link
Copy Markdown
Contributor

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
Copy Markdown

Would love to see this get merged 🚀

@palmtown

palmtown commented Oct 6, 2023

Copy link
Copy Markdown

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

@s-dupuis

Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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

bompus commented Aug 29, 2024

Copy link
Copy Markdown
Contributor Author

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

thematan commented Dec 9, 2024

Copy link
Copy Markdown

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
Copy Markdown

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