【发布时间】:2016-07-20 17:36:36
【问题描述】:
mongoimport 命令返回正确数量的文档,并添加一个新集合,但是当我尝试打开我的数据库时,什么也没有。我正在使用 json 数组来存储我的数据,但不确定为什么这不起作用。
C:\Program Files\MongoDB\Server\3.2\bin>mongoimport --db playerList --collection data --jsonArray --file ../../../../../nodeProjects/public/data.json
2016-07-20T09:30:05.807-0700 connected to: localhost
2016-07-20T09:30:05.813-0700 imported 1 document
C:\Program Files\MongoDB\Server\3.2\bin>mongo
MongoDB shell version: 3.2.7
connecting to: test
> use playerList
switched to db playerList
> db.playerList.find().pretty()
> db.getCollectionNames()
[ "data" ]
我的 data.json 文件是。
[{"name":"A.J. Green","team":"CIN","pos":"WR","weeklyPts":[{"week":1,"pts":6.3},{"week":2,"pts":10.5},{"week":3,"pts":34.7}]}]
【问题讨论】:
标签: json mongodb mongoimport