-
Notifications
You must be signed in to change notification settings - Fork 657
Description
Create a collection with one string type property . Then insert a few data like the next example:
Bla
bla
Ala
ala
When you query with sort set to 1, for example:
http://localhost:2403/example/?_jsonquery={%22$sort%22:{%22title%22:1}}
The expected object would be:
Ala
ala
Bla
bla
But the returned object is:
Ala
Bla
ala
bla
This is a MongoDB problem but I found the solution without modifying the database collection. We need to add to the query a collation object with locale and strength, like the next example (extracted from here:
collection.find({ 'city' : 'New York' }, { '_id' : 0 }, { 'collation' : { 'locale' : 'en_US' , 'strength' : 2 }}).toArray(function(err, docs) {
assert.equal(err, null);
callback(docs);
});
So, the solution is to insert the collation to the query, there was two alternatives:
- put the collation, for example, in the stripOptions function here
- allow to set the collation property in ctx.query
The first option is working for me, but I want to do a pull request and I`m sure that isn't the way. So I've started to implement the second solution but the collation property doesn't reach the db.js. I think there is a file that I haven't got in consideration between the get.js -> ?? -> db.js