[solved] Storing numbers as numbers, not strings


I have documents stored in this format where ‘sort’ field defines sort order on the client:


But meteor stores sort values as strings instead of numbers.
So if I query


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?

Or maybe it’s just Meteor’s way of parsing this data?
When I connect to mongodb directly (using Robomongo) and query for


it gives me correctly sorted output.


Ok carefully auditing the db, I’ve found that I actually had mixed values in this field - strings and numbers! :stuck_out_tongue_closed_eyes:
Nutting wrong with Meteor here)
So if anybody runs into similar prob - make sure you store nums as nums in your db)


The joy of dynamic typing and schema-less DB :wink:
Typescript to the rescue…