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

Allow passing collation (or other extended options) to mongoDB query #1603

Open
mrkswrnr opened this issue Mar 25, 2021 · 0 comments
Open

Allow passing collation (or other extended options) to mongoDB query #1603

mrkswrnr opened this issue Mar 25, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@mrkswrnr
Copy link

Is your feature request related to a problem? Please describe.
To retrieve users by their email address, I would like to use a (previously created) collation index. Unfortunately I can't pass the necessary options to the find method of the mongo client. In the MongoDriver unknown FindOneOptions/FindOptions-properties are not passed to the MongoConnection or mongodb.collection.find.

Describe the solution you'd like
I would like to pass a property collation in the FindOptions for findOne or find, which is passed directly to the mongodb.collection.find function.

Describe alternatives you've considered
Instead of using a collation index, I could make the search case-insensitive by using a regular expression. However, this does not seem to me to be the recommended way.

Alternatively, I could set the collation for the entire collection, which would result in this collation being used by default - without having to include the collation in the FindOptions. But then all other queries would also use this collation, which is not desired e.g. for first/last names.

Additional context
I could imagine different approaches to solve this problem:

  1. the find methods in MongoDriver and MongoConnection are extended by options.collation.
  2. the find methods are changed so that excess options are passed directly to the mongo.collection.find method.
  3. another hook beforeFind allows to manipulate the query (this seems to me a disproportionate amount of effort to fulfill this requirement, but might allow future use cases)

Is this feature something you would consider? In any case, thanks for the work on MikroORM!

@mrkswrnr mrkswrnr added the enhancement New feature or request label Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant