插入使用mongoexport导出的RockMongo JSON集合

时间:2015-03-26 12:39:35

标签: mongodb mongoexport

我从本地数据库导出数据到托管有问题。我使用以下命令导出数据:

 mongoexport --db fol -c like --out exportfol.like.json

并获得了如下所示的json文件:

 { "_id" : { "$oid" : "550acb815fa67ddc1aa67633" }, "to" : 263449651, "from" : 264717017, "fromDate" : { "$date" : "2015-03-19T16:13:37.070+0300" }, "mutual" : false }
{ "_id" : { "$oid" : "550c20d08eecd30c15e4a207" }, "from" : 12680198, "to" : 1385847, "fromDate" : { "$date" : "2015-03-20T16:29:52.004+0300" }, "mutual" : false }
{ "_id" : { "$oid" : "550c313e8eecd30c15e4a208" }, "to" : 35545833, "from" : 12680198, "fromDate" : { "$date" : "2015-03-20T17:39:58.218+0300" }, "mutual" : false }
{ "_id" : { "$oid" : "5512aa5ec1baea98151dd403" }, "from" : 12680198, "to" : 13666889, "fromDate" : { "$date" : "2015-03-25T15:30:22.967+0300" }, "mutual" : false }

当我尝试在rockmongo中导入此数据时,问题就开始了。当我从json文件导入集合时,我正在获取exeption

exception: field names cannot start with $ [$oid] at src/mongo/shell/collection.js:159

有没有办法将数据移植到rockmongo?

1 个答案:

答案 0 :(得分:1)

您可以编辑好文件:

{"_id" : 550acb815fa67ddc1aa67633", "to" : 263449651, "from" : 264717017, "fromDate" : { "$date" : "2015-03-19T16:13:37.070+0300" }, "mutual" : false }
{"_id" : 550c20d08eecd30c15e4a207", "from" : 12680198, "to" : 1385847, "fromDate" : { "$date" : "2015-03-20T16:29:52.004+0300" }, "mutual" : false }
{"_id" : 550c313e8eecd30c15e4a208", "to" : 35545833, "from" : 12680198, "fromDate" : { "$date" : "2015-03-20T17:39:58.218+0300" }, "mutual" : false }
{"_id" : 5512aa5ec1baea98151dd403", "from" : 12680198, "to" : 13666889, "fromDate" : { "$date" : "2015-03-25T15:30:22.967+0300" }, "mutual" : false }

然后再试一次