Meteor and mongodb - reorder items


I have the following schema

"_id" : “PbSkep5Auv9ZBeEyR”,
“item” : “Footage”,
“permalink” : “footage”,
“itemIndex” : 23,

When I paste them in my remote DB it order them by _id, which seems to be a automatic meteor key. I am using robomongo and am trying to reorder the items by ‘itemIndex’ permanently . How do I do this?


You have to do it in your publications and in the helper or in your route for the template.

For example :

Meteor.publish(‘schema’, function(){
return Schema.find({}, {sort: {itemIndex: 1}});

Subscribe in the client Meteor.subscribe(‘schema’);

And in the helper or route:

schema: function () {
return Schema.find({}, {
sort: { itemIndex: 1 }

Hope it works.


perfect found it in the publish setttings

Meteor.publish('items', function() {

      return Items.find({}, {sort: {itemIndex: 1}});


Make sure you also sort them when you request the data client-side, otherwise with reactive data you can run into a situation where items aren’t sorted properly