0

我在将数据从本地数据库导出到主机时遇到问题。我用这个命令导出数据:

 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 文件导入集合时,我得到了异常

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

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

4

1 回答 1

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 }

然后再试一次

于 2015-08-30T07:07:48.600 回答