Kai
Kai

Reputation: 417

How test if _ensureIndex is working?

Is there some way to display the index – and see if it is working? Thanks!

I'm building it at startup:

// create a compound index
if (Meteor.isServer) {
    Meteor.startup(function() {
        MyPix.files._ensureIndex({'metadata.tags': 1, 'original.name': 1, 'uploadedAt': -1})
    })
}

Upvotes: 0

Views: 311

Answers (3)

Kai
Kai

Reputation: 417

Not sure if any of these are correct, but both seem to return empty Arrays. Does it mean there is not index?

meteor:PRIMARY> show collections
cfs.MyPix.filerecord
cfs._tempstore.chunks
system.indexes
meteor:PRIMARY> db.cfs.MyPix.getIndexes()
[ ]
meteor:PRIMARY> db.MyPix.getIndexes()
[ ]

Upvotes: 0

Delgermurun
Delgermurun

Reputation: 658

You can use mongodb's getIndexes method.

meteor mongo
db.files.getIndexes()

Or you can use mongodb's cursor explain.

meteor mongo
db.files.find(<query>).explain()

Upvotes: 1

Tarang
Tarang

Reputation: 75955

You can connect via meteor mongo

and then run

show collections

Select the collection that corresponds to MyPix, say it says mypix

db.mypix.getIndexes();

Upvotes: 1

Related Questions