Skip to content

Conversation

@avaly
Copy link
Collaborator

@avaly avaly commented Feb 6, 2023

This PR adds support for mongodb v5.

Together with this we're switching to the StrictFilter types.

Because this is changing the implementation of the internal types and has potential to break existing applications, I think this should be a major version bump. Happy to hear other arguments though.

  • Upgrade mongodb to 5.0.0
  • Use StrictFilter types
  • Use StrictUpdateFilter types
  • Update MongoDB API docs links

@avaly avaly self-assigned this Feb 6, 2023
Comment on lines +105 to +108
"@typescript-eslint/no-unsafe-argument": "warn",
"@typescript-eslint/no-unsafe-assignment": "warn",
"@typescript-eslint/no-unsafe-member-access": "warn",
"@typescript-eslint/no-unsafe-return": "warn",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some weird reason, the ESLint TS plugin now thinks the type of the update filter variables are any, so let's temporarily downgrade these to warning.

@vanstinator
Copy link
Contributor

Agreed on the major version bump.

@marafat
Copy link
Contributor

marafat commented Feb 6, 2023

What is the TL;DR on the difference between Filter and StrictFilter?

@avaly
Copy link
Collaborator Author

avaly commented Feb 6, 2023

What is the TL;DR on the difference between Filter and StrictFilter?

Filter in v5.0.0 is the pre-v4.3.0 Filter type, which does not support dot-notation fields.

StrictFilter in v5.0.0 is the post-v4.3.0 Filter type, which does support dot-notation fields.

@marafat
Copy link
Contributor

marafat commented Feb 6, 2023

Oh, well that is not bad, so they just decided to isolate the support for dot-notation fields in its own type instead of removing it completely?

marafat
marafat previously approved these changes Feb 6, 2023
@ejmartin504
Copy link
Contributor

Because this is changing the implementation of the internal types and has potential to break existing applications, I think this should be a major version bump. Happy to hear other arguments though.

From looking at the changes, I'm having trouble understanding what this would break in external applications.

However, since this does involve a major version upgrade of the mongodb library, I think that's enough to merit a major version update.

@avaly avaly force-pushed the feature/mongodb-v5-strictfilter branch 3 times, most recently from e5a4947 to e592470 Compare February 7, 2023 17:53
@ejmartin504
Copy link
Contributor

ejmartin504 commented Feb 7, 2023

Worth pinning to 5.0.1? https://github.com/mongodb/node-mongodb-native/releases/tag/v5.0.1 (or is that moot with the peerDep set)

@avaly avaly force-pushed the feature/mongodb-v5-strictfilter branch from e592470 to 0534bb7 Compare February 8, 2023 09:52
@avaly
Copy link
Collaborator Author

avaly commented Feb 8, 2023

I updated our dev dependency to 5.0.1, but given the peer dependency version is more of an indicator of breaking changes which we depend on, I'll keep that version declared as >=5.0.0 and consumers can upgrade at their own pace to subsequent v5 versions.

marafat
marafat previously approved these changes Feb 9, 2023
ejmartin504
ejmartin504 previously approved these changes Feb 10, 2023

Papr is using the strict types to provide type safety for all query and update filters.

This comes with a caveat: whenever you need to interact with the `mongodb` driver collections, you need to cast filter types to their simple counterparts, since `Filter` is not compatible with `StrictFilter`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit of the docs is very nicely written, well done!

@avaly avaly force-pushed the feature/mongodb-v5-strictfilter branch from 0534bb7 to ab1e0e4 Compare February 13, 2023 09:42
@avaly avaly dismissed stale reviews from ejmartin504 and marafat via bba476a February 13, 2023 09:49
@avaly avaly force-pushed the feature/mongodb-v5-strictfilter branch from ab1e0e4 to bba476a Compare February 13, 2023 09:49
BREAKING CHANGE: `mongodb` v5 is required as a peer dependency.

BREAKING CHANGE: `Filter` and `UpdateFilter` types are now using the strict
counterpart types from mongodb v5.
@avaly avaly force-pushed the feature/mongodb-v5-strictfilter branch from bba476a to 73b7148 Compare February 13, 2023 09:53
@avaly avaly merged commit 547a794 into main Feb 13, 2023
@avaly avaly deleted the feature/mongodb-v5-strictfilter branch February 13, 2023 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants