You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mongo 3.4 added support for collation in string comparisons, for finding and sorting. This enables, among other things, sorting while ignoring case and accent differences based on a provided locale.
With a plain Mongo JS client, a case-insensitive sort would use cursor.collation:
Tests: The one slightly tricky part with the tests is that Share runs its tests against Mongo server 2.6, 3.6, and 4.0, and collation won't work when running against 2.6. I believe it should be possible to have the test code check the MONGODB_VERSION env variable set in Travis and conditionally run specific test cases that way.
Error handling: Since collation was added in Mongo 3.4, any server versions before that will not handle collation.
Whoever implements this should check behavior against older servers and make sure something sensible happens error-wise.
Background
Mongo 3.4 added support for collation in string comparisons, for finding and sorting. This enables, among other things, sorting while ignoring case and accent differences based on a provided locale.
With a plain Mongo JS client, a case-insensitive sort would use
cursor.collation
:With a larger result set, a matching case-insensitive index would also be desirable for performance.
sharedb-mongo doesn't support collations yet in queries. Yet! That's what this is about.
In the meantime, there are some workarounds for doing case-insensitive sorting.
Implementation
Thankfully, it's straightforward to add support in sharedb-mongo for collation.
The usage that's equivalent to the Mongo JS driver example above would look like this:
sharedb-mongo has a map from dollar-prefixed query properties to cursor methods, and supporting collation is as easy as adding a
$collation
entry.There are a couple additional pieces:
MONGODB_VERSION
env variable set in Travis and conditionally run specific test cases that way.cursor.collation
. Users can pass in a pre-created Mongo client, though, which may be an issue.The text was updated successfully, but these errors were encountered: