I have documents stored in this format where ‘sort’ field defines sort order on the client:
{_id:...,sort:1},{_id:...,sort:2},{_id:...,sort:10},{_id:...,sort:20}
But meteor stores sort values as strings instead of numbers.
So if I query
Docs.find({},{sort:{sort:1}})
gives me this sort order: 1,10,2,20 - whereas I want it naturally to be 1,2,10,20.
How can I store numbers as numbers?
UPDATE:
Or maybe it’s just Meteor’s way of parsing this data?
When I connect to mongodb directly (using Robomongo) and query for
db.getCollection('docs').find({}).sort({sort:1})
it gives me correctly sorted output.