【问题标题】:Unable to drop Mongodb index in Meteor.js无法在 Meteor.js 中删除 Mongodb 索引
【发布时间】:2015-05-30 22:29:06
【问题描述】:

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

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

这会产生错误MongoError: invalid index name spec

【问题讨论】:

    标签: javascript node.js mongodb meteor minimongo


    【解决方案1】:

    _1 添加到索引名称:

    Games._dropIndex('test_1')

    【讨论】:

      【解决方案2】:

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

      要解析,请将 drop 的索引指定为参数。您可以通过索引名称或索引规范文档指定索引。

      您还可以使用db.collection.dropIndexes() 命令来remove all indexes,但集合中的_id 索引除外。

      【讨论】:

        猜你喜欢
        • 2013-09-10
        • 2019-07-26
        • 2016-11-05
        • 1970-01-01
        • 2012-01-31
        • 1970-01-01
        • 1970-01-01
        • 2023-03-04
        • 2011-12-29
        相关资源
        最近更新 更多