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

Add case insensitive indexes support #414

Closed
angfal opened this issue Jan 31, 2018 · 8 comments
Closed

Add case insensitive indexes support #414

angfal opened this issue Jan 31, 2018 · 8 comments

Comments

@angfal
Copy link
Contributor

angfal commented Jan 31, 2018

Description

MongoDB allows to create and search by case insensitive indexes. The problem to support this feature it's required to execute separate "collation" function for a MongoDB cursor which is hidden by loopback and no way to receive access to it. As the result, no a reasonable way somehow wrap loopback functions to use such functionality via loopback.

Ideally, it would be great to add the support of this parameter for loopback MongoDB connector. For example using filter:

Model.find({
    where: {...}, 
    collation: {
        locale : <locale>,
        strength : <strength>
    }
});

// mongodb.js:
MongoDB.prototype.all = function all(model, filter, options, callback) {
    ...
    function processResponse(err, cursor) {
        ...
       if (filter.collation) {
           cursor.collation(filter.collation)
       }
        ...
    }
}

or using options (to not corrupt filter schema which common for all datasource)

Model.find({where: {...}}, {
    collation: {
        locale : <locale>,
        strength : <strength>
    }
});

Links:

@kjdelisle
Copy link
Contributor

@angfal Pull requests are welcome. My experience with mongodb is somewhat limited, though your 2nd proposal sounds solid to me. If you're willing to make a PR with test coverage, I'll review it and help you land it. :)

@angfal
Copy link
Contributor Author

angfal commented Feb 14, 2018

@kjdelisle Great! I will make the required fixes

@stale
Copy link

stale bot commented Apr 15, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 15, 2018
@angfal
Copy link
Contributor Author

angfal commented Apr 15, 2018

Please, somebody review my pr

@stale stale bot removed the stale label Apr 15, 2018
@stale
Copy link

stale bot commented Jun 14, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 14, 2018
@angfal
Copy link
Contributor Author

angfal commented Jun 14, 2018

Additional info in the PR

@stale stale bot removed the stale label Jun 14, 2018
b-admike added a commit that referenced this issue Oct 23, 2018
Add case insensitive indexes support
@barocsi
Copy link

barocsi commented Nov 21, 2018

ok so how to use it within a query?

@angfal angfal closed this as completed Jan 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants