2

How can a collection's index be dropped from a Meteor server?

Games._dropIndex()
Games._ensureIndex({
    name: 'text', 
    description: 'text'
})

This gives an error MongoError: invalid index name spec

Nyxynyx
  • 61,411
  • 155
  • 482
  • 830

2 Answers2

2

The error you are getting is as a result of not supplying the dropIndex() method with the parameter of the index you are trying to remove.

To resolve, specify the index to drop as the parameter. You can specify the index either by the index name or by the index specification document.

You can also use the db.collection.dropIndexes() command to remove all indexes, except for the _id index from a collection.

chridam
  • 100,957
  • 23
  • 236
  • 235
0

Add _1 to index name:

Games._dropIndex('test_1')

comerc
  • 123
  • 1
  • 5