"MongoDB append to document array (moved from Getting Started section)"
I'm attempting to add an item to an array within a document in MongoDB. For example, here's the initial document.
对不起,我不小心和发布这个问题er Getting Started. Problems and Support is more appropriate.
I want to add this item to the modelResults array:
{
"_id" : ObjectId("55bfa1619b527d2ffb37439e"),
"modelName": "Model Sample A1",
"modelResults" : [
{
"resultID" : "1",
"name" : "Result 1 Name",
"resultStuff" : "1000"
},
{
"resultID" : "2",
"name" : "Result 2 Name",
"resultStuff" : "2000"
},
{
"resultID" : "3",
"name" : "Result 3 Name",
"resultStuff" : "3000"
},
{
"resultID" : "4",
"name" : "Result 4 Name",
"resultStuff" : "4000"
}
]
}
The command in MongoDB (outside of RapidMiner) would be:
{
"resultID" : "6",
"name" : "Result 6 Name",
"resultStuff" : "6000"
}
I want the result to look like this without having to read in the entire modelResults array and append the new item to it in RapidMiner and write the entire modelResults array back to MongoDB.:
db.mvstuff.update({modelName:"Model Sample A1"},{$push : {modelResults : {
"resultID" : "6",
"name" : "Result 6 Name",
"resultStuff" : "6000"
} }})
{Here's an example process, but I've not been able to get the desired results:
"_id" : ObjectId("55bfa1619b527d2ffb37439e"),
"modelName": "Model Sample A1",
"modelResults" : [
{
"resultID" : "1",
"name" : "Result 1 Name",
"resultStuff" : "1000"
},
{
"resultID" : "2",
"name" : "Result 2 Name",
"resultStuff" : "2000"
},
{
"resultID" : "3",
"name" : "Result 3 Name",
"resultStuff" : "3000"
},
{
"resultID" : "4",
"name" : "Result 4 Name",
"resultStuff" : "4000"
},
{
"resultID" : "6",
"name" : "Result 6 Name",
"resultStuff" : "6000"
}
]
}
Thanks for your help and comments!
<宏/ >
<描述一致= "分er" color="transparent" colored="false" width="126">set up criteria
<描述一致= "分er" color="transparent" colored="false" width="126">clean up the result of the previous try
<描述一致= "分er" color="transparent" colored="false" width="126">set up item to add to array
<描述一致= "分er" color="transparent" colored="false" width="126">get the doc to review the results
<描述一致= "分er" color="green" colored="true" height="72" resized="true" width="270" x="496" y="215">insert the initial document
对不起,我不小心和发布这个问题er Getting Started. Problems and Support is more appropriate.
Tagged:
0