我对 mongodb 很陌生,我刚刚创建了一个database
名称Test
,里面有一个collection
叫projects
我有一个 json 文件,其中包含 2 个这样的项目:
{
"-KutvlMPRHGWWTgk1Mh4" : {
"isPrivate" : true,
"proj_contact" : "blMufEZjv6ZmnugDlTruzGwmowI3",
"proj_creator" : "blMufEZjv6ZmnugDlTruzGwmowI3",
"proj_date" : "01/01/2017",
"proj_des" : "this is a testing projectasfasfasgasg",
"proj_name" : "Project",
"proj_pi" : "qCQee2pWGeN9PD3FRXbJpdN7mHT2"
},
"-KvARDkcsCEKZgnM94xH" : {
"isPrivate" : false,
"proj_autho" : [ "Lei0ohIcMBbzVtcQD1AgU4wHBKR2", "OnjEOFSNVpf189J9hAaSFWOZdl42", "0DwfVUeMAraiRxFZTa6xyjn6sfx2", "WHjFSvEo45U7ULzwIQdnUz6ytXp1", "kKTWt36bIifrRzpqNP1l2Gnl3KU2" ],
"proj_contact" : "kKTWt36bIifrRzpqNP1l2Gnl3KU2",
"proj_creator" : "kKTWt36bIifrRzpqNP1l2Gnl3KU2",
"proj_date" : "10/12/2017",
"proj_des" : "this is a test :)",
"proj_name" : "another test",
"proj_pi" : "qCQee2pWGeN9PD3FRXbJpdN7mHT2"
}
}
所以我想将它导入到projects collection
. 我正在运行这个命令
mongoimport --db Test --collection projects --file import-file.json
但事情是我得到的结果是 mongodb 只创建一个包含整个内容的索引( 1 id ) 。
我想要的是在导入之后,mongodb 将为上面的每个项目创建2 个不同的索引(2 个 id)
谢谢