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

Update to MongoDB 5 #6383

Closed
loan-laux opened this issue Oct 27, 2021 · 6 comments · Fixed by #6588 · May be fixed by reactioncommerce/api-core#41 or reactioncommerce/reaction-file-collections#150
Closed

Update to MongoDB 5 #6383

loan-laux opened this issue Oct 27, 2021 · 6 comments · Fixed by #6588 · May be fixed by reactioncommerce/api-core#41 or reactioncommerce/reaction-file-collections#150
Assignees
Labels
core work For issues that track feature development work being done by core Reaction developers

Comments

@loan-laux
Copy link
Collaborator

MongoDB 4.2 will reach EOD soon. We should update to MongoDB 5 (if there are even breaking changes at all).

@loan-laux loan-laux added the core work For issues that track feature development work being done by core Reaction developers label Oct 27, 2021
@brent-hoover
Copy link
Collaborator

There are some significant breaking changes between the 4.x driver (which is required for 5) and the current 3.x driver

None of them are crazy hard to fix but the current code will absolutely not work with 4.x

@brent-hoover
Copy link
Collaborator

The two major changes I encountered was:

  1. The way you instantiate the driver is different. https://github.com/mongodb/node-mongodb-native/blob/4.1/docs/CHANGES_4.0.0.md
  2. If you are using something like findOneAndUpdate you must change returnOriginal: false to returnDocument: "after" if you want the updated document. This one is critical because it will not throw an error but just give you the old document

@janus-reith
Copy link
Collaborator

This one is critical because it will not throw an error but just give you the old document

Wow, changes like this are hard to understand.

@janus-reith
Copy link
Collaborator

janus-reith commented Nov 25, 2021

I wonder if we could just provide an easy migration path here to keep compatibility.

Especially regarding that case of returnOriginal, since calls don't go right to the mongodb package but context.collections, we could use that as a wrapper and set returnDocument accordingly and maybe log a warning about it being deprecated.
Same for other potential breaking changes.

That way required changes could be limited to api-core and other packages could be migrated gradually.

@brent-hoover
Copy link
Collaborator

Just coming back to this to say that these changes go even deeper because RC relies on certain elements of the Mongo driver that no longer exist. This affects how pagination works and a bunch of things. This will need to be a significant engineering effort

@brent-hoover
Copy link
Collaborator

That being said Mongo 4.4 is not End of Life until Feb of 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core work For issues that track feature development work being done by core Reaction developers
Projects
None yet
4 participants