如何从 Meteor 服务器中删除集合的索引?
Games._dropIndex()
Games._ensureIndex({
name: 'text',
description: 'text'
})
这给出了一个错误MongoError: invalid index name spec
如何从 Meteor 服务器中删除集合的索引?
Games._dropIndex()
Games._ensureIndex({
name: 'text',
description: 'text'
})
这给出了一个错误MongoError: invalid index name spec
您得到的错误是由于没有为dropIndex()
方法提供您尝试删除的索引的参数。
要解决此问题,请将要删除的索引指定为参数。您可以通过索引名称或索引规范文档来指定索引。
您还可以使用该db.collection.dropIndexes()
命令删除所有索引_id
,集合中的索引除外。
添加_1
到索引名称:
Games._dropIndex('test_1')