How to create mongo indexes inside the meteor code?

im new to meteor, i used mongo before, but there wasn’t any way to implement indexes to speed up the db unless i manually write that in the mongo on terminal, Does meteor provides to do that programmatically ?

1 Like

Look here: Collection._ensureIndex creating several indexes?

_ensureIndex was updated.

MyCollection.rawCollection().createIndex({ timestamp: -1 });

MyCollection.rawCollection().dropIndex({ timestamp: -1 });

Unique indexes: https://docs.mongodb.com/manual/core/index-unique/

4 Likes