-1

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'. How do I do this?

LeBlaireau
  • 17,133
  • 33
  • 112
  • 192
  • 2
    Have you tried using your favorite search engine to look for "meteor order by"? Also these: http://stackoverflow.com/a/11517713/4665459 and http://stackoverflow.com/q/13957691/4665459 – Mark Leiber Sep 22 '15 at 10:39

1 Answers1

1

robomongo or other UI have nothing to do with the order of the data: you need to specify this in your query.

lookup the Mongo documentation:

db.collection.find({}).sort( { itemIndex: -1 } )

or

db.collection.find( { $query: {}, $orderby: { itemIndex : -1 } } )

http://docs.mongodb.org/v3.0/reference/operator/meta/orderby/

MrE
  • 19,584
  • 12
  • 87
  • 105