I want to add documents in descending order while add them in my collection. To avoid querying later. I tried in mongodb docs which specifies to query after insertion. Is it possible to add documents to collection in descending order by date while inserting the document as i don’t want to query and return the top 50 documents.
ehh what you’re asking is basic Meteor stuff, sounds like you need to do some more tutorials.
But in any case the asnwer is no. But the real issue here is that when you’re displaying info you’re always using the
.find() command. And find does have a sort option, it’s got nothing to do with insert.
I will just add that if you intend ordering/filtering by date (whether ascending or descending) you should always ensure you have an index on your date column(s). You may add this using the MongoDB shell or within your Meteor server code. The common pattern for this is in the