【问题标题】:Is there any way to get all the _id in mongo which has string values有什么方法可以获取 mongo 中具有字符串值的所有 _id
【发布时间】:2016-02-01 12:15:01
【问题描述】:

在其中一个集合中,我们在集合中的条目为 "_id":"123" 另一个为 "_id": NumberLong(123)..

有没有办法通过 mongo cli 删除所有带有 _id 作为字符串类型而不是 Long 的条目?

【问题讨论】:

    标签: mongodb mongodb-query


    【解决方案1】:

    您可以使用 $type 运算符来识别各种数据类型

    db.user_data.remove( { _id: {$type : 2}})

    https://docs.mongodb.org/manual/reference/operator/query/type/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-20
      • 1970-01-01
      • 2014-04-28
      相关资源
      最近更新 更多