mongodb使用一个json upsert多个文档

时间:2015-01-29 11:40:27

标签: json mongodb

我收到包含多个文档的JSON数据,我可以使用collection.insert

将该数据插入到mongodb集合中

一旦我填充了我的集合,我就可以收到一份JSON数据的子集,其中包含原始数据的更新(编辑和新文档)。我知道我可以将我的JSON分成单独的文档来循环使用

collection.update{ id: <document id> },
{
 <document to update>;
},
{ upsert: true }

每个文档都要将它添加到我的集合中,但是有没有办法根据匹配的ID来包含多个文档的JSON,因为我可以使用collection.insert

0 个答案:

没有答案