2

如何从 Meteor 服务器中删除集合的索引?

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

这给出了一个错误MongoError: invalid index name spec

4

2 回答 2

2

您得到的错误是由于没有为dropIndex()方法提供您尝试删除的索引的参数。

要解决此问题,请将要删除的索引指定为参数。您可以通过索引名称或索引规范文档来指定索引。

您还可以使用该db.collection.dropIndexes()命令删除所有索引_id,集合中的索引除外。

于 2015-05-24T18:15:41.387 回答
0

添加_1到索引名称:

Games._dropIndex('test_1')

于 2016-06-29T10:37:56.727 回答