2016-04-05 27 views
0

我有一个MongoDB集合与下列文档。有些文件有1个字段,有些文件有2个。我有兴趣只出口那些有“productid”字段的文件。我正在使用下面的查询,但得到错误:“不能将字符串解组成GO类型map [string] interface {}”的值。MongoExport错误 - 不能解组字符串

文件看起来是这样的:

[ 
    { 
    "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"

回答

0

我通过更新我的脚本来修复这个问题:

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"