Skip to content

Conversation

@avaly
Copy link
Collaborator

@avaly avaly commented Feb 15, 2023

Closes #410 #407

This PR brings the strict filter types from mongodb into our repository, which allows us to remove the Document type and enhance the strictness of these types.

Known divergence from the mongodb types:

  • added $expr support to the root filter operators
  • $elemMatch is applied only for array fields
  • removed support for recursive types in the dot-notation path algorithm
  • reduced maximum depth level to 6 in the dot-notation path algorithm
  • added support for non-indexed array elements in the dot-notation path algorithm, e.g. foo.bar (where foo is an array of objects)
  • added support for indexed array elements in the dot-notation path algorithm, e.g. foo.0 (where foo is an array of objects)

Copy link
Contributor

@ejmartin504 ejmartin504 left a comment

Choose a reason for hiding this comment

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

I can't really say that I fully understand all the TS, but a quick look doesn't raise any red flags for me.

You mentioned a few things in the PR description that I didn't quite follow, would you mind expanding on these, or pointing where they are in the code, for those following along at home?

  • added $expr support to the root filter operators -- What is this? Why was this not supported by mongo?
  • added support for non-indexed array elements in the dot-notation path algorithm, e.g. -foo.bar (where foo is an array of objects) -- What is the use case for this? Is this query pattern supported by the mongo server?
  • added support for indexed array elements in the dot-notation path algorithm, e.g. foo.0 (where foo is an array of objects) -- surprised this wasn't supported by mongo if this is a valid query pattern, is this query pattern supported by the mongo server?

Also, I'm curious how we plan to keep these types in sync with mongodb types themselves.

@avaly
Copy link
Collaborator Author

avaly commented Feb 15, 2023

added $expr support to the root filter operators -- What is this? Why was this not supported by mongo?

https://www.mongodb.com/docs/v5.3/reference/operator/query/expr/

$expr is a root filter operator. It was never defined in the mongodb types.

This was possible to use because of the Document being used everywhere in those types, which accepted any unknown property.

added support for non-indexed array elements in the dot-notation path algorithm, e.g. -foo.bar (where foo is an array of objects) -- What is the use case for this? Is this query pattern supported by the mongo server?

https://www.mongodb.com/docs/v5.3/tutorial/query-array-of-documents/#specify-a-query-condition-on-a-field-embedded-in-an-array-of-documents

added support for indexed array elements in the dot-notation path algorithm, e.g. foo.0 (where foo is an array of objects) -- surprised this wasn't supported by mongo if this is a valid query pattern, is this query pattern supported by the mongo server?

https://www.mongodb.com/docs/v5.3/tutorial/query-arrays/#query-for-an-element-by-the-array-index-position

@avaly avaly force-pushed the feature/import-strict-filter-types branch 2 times, most recently from 05acce9 to ab1922b Compare February 15, 2023 17:33
marafat
marafat previously approved these changes Feb 16, 2023
@avaly avaly force-pushed the feature/import-strict-filter-types branch 3 times, most recently from 1d0a0fe to 2fc4329 Compare February 17, 2023 11:00
@avaly avaly requested review from ejmartin504 and marafat February 17, 2023 11:01
@avaly avaly force-pushed the feature/import-strict-filter-types branch 2 times, most recently from f5aa6ce to 2a0c81d Compare February 22, 2023 10:40
BREAKING CHANGE: Papr is using new internal stricter types for query filters and update
filters: `PaprFilter` and `PaprUpdateFilter`.
@avaly avaly force-pushed the feature/import-strict-filter-types branch from 2a0c81d to 58a50c4 Compare February 22, 2023 10:48
@avaly avaly merged commit b54ef0b into main Feb 22, 2023
@avaly avaly deleted the feature/import-strict-filter-types branch February 22, 2023 10:52
@avaly avaly mentioned this pull request Feb 22, 2023
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.

Own dot-notation filter types

4 participants