I have client side only (local) Meteor collection defined like that (coffeescript):
Products = new Meteor.Collection null
However when I try to find() providing sorting parameters Meteor tells me that sorting of local collections is not supported. This is understandable.
I would like to know what is the easiest/simplest way to get sorted results. Essentially I always use all the data in the Collection, so keeping it in sorted state would solve the problem.
It works for me, are you using the latest version of Meteor? Running this code works on the Meteor Docs site:
var foos = new Meteor.Collection( null );
for ( var i = 0; i < 100; i++ ) {
foos.insert({ num: i });
}
foos.findOne( {} ).num; // => 0
foos.findOne( {}, { sort: [[ "num", "desc" ]] } ).num; // => 99
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With