【问题标题】:MongoExport error - cannot unmarshal stringMongoExport 错误 - 无法解组字符串
【发布时间】:2016-04-07 06:14:20
【问题描述】:

我有一个包含以下文档的 MongoDB 集合。有些文档有 1 个字段,有些有 2 个。我只对导出具有“productid”字段的文档感兴趣。我正在使用下面的查询,但收到错误:“无法将字符串解组为 map[string] interface {} 类型的 GO 值”。

文档如下所示:

[
  {
     "id" : 1,
  },
  {
     "id" : 2,
  },
  {
     "id" : 3
     "Product Info":
      {
         "ProductName" : "test"
      }
  }
]

我使用的 MognoExport 命令如下:mongoexport --username x --password x --host x --db mydb --collection mycol --query '{"Product Info.ProductName":{"$exists":true}}' --type=csv --fields id,productid --out "c:\myfile.csv"

【问题讨论】:

    标签: mongodb csv mongoexport


    【解决方案1】:

    我通过将脚本更新为:

    mongoexport --username x --password x --host x --db mydb --collection mycol --query "{ 'Product Info.ProductName':{$exists:true}}" --type=csv --fields id,productid --out "c:\myfile.csv"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-10
      • 1970-01-01
      • 2019-11-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-17
      • 1970-01-01
      • 2019-03-26
      相关资源
      最近更新 更多