1
我是新的MongoDB。 我有一個名爲「surveyCollection」的集合。 我插入一些數據來收集與殼牌,MongoDB JsonObject和JsonArray
db.surveyCollection.insert({
"count":30,
"people": [
{
"firstName":"John",
"lastName":"Jason"
}
]
})
db.surveyCollection.insert({
"count":30,
"people": [
{
"firstName":"Sarah",
"lastName":"Smith"
}
]
})
而且我有如下數據(db.surveyCollection.find()漂亮());
{
"_id" : ObjectId("5873d0c86c3319a579754d00"),
"count" : 30,
"people" : [
{
"firstName" : "John",
"lastName" : "Jason"
}
]
}
{
"_id" : ObjectId("5873d0c86c3319a579754d00"),
"count" : 30,
"people" : [
{
"firstName" : "Sarah",
"lastName" : "Smith"
}
]
}
我不知道我怎麼可以插入一個新的人與任何調查。我的意思是,我想要有如下的數據;
{
"_id" : ObjectId("5873d0c86c3319a579754d00"),
"count" : 30,
"people" : [
{
"firstName" : "John",
"lastName" : "Jason"
}
]
}
{
"_id" : ObjectId("5873d0c86c3319a579754d00"),
"count" : 30,
"people" : [
{
"firstName" : "Sarah",
"lastName" : "Smith"
},
{
"firstName" : "George",
"lastName" : "Smith"
}
]
}
我的意思是,我怎麼能達到JsonArray的值?
謝謝
非常感謝,我一直在努力工作2個小時。 – Aybuke
沒問題。很高興我能幫上忙 :) – superUser