Voy a suponer que por caro te refieres al tiempo de ejecución. En ese caso, desea un createdAt
campo, un índice secundario en createdAt
, y usar un findOne()
declaración. Para crear el índice en createdAt
para su colección, haga:
myCol._ensureIndex({ createdAt: -1 });
Luego en tu publicación:
Meteor.publish('myCol', function () {
return MyCol.find({userId: this.userId}, { sort: { createdAt: -1 } });
});