我想在单个请求中在mongodb集合中执行多个更新。对于Ex
数据库中现有的
{ "_id" : 1, "name" : "Central Perk Cafe", "violations" : 3 }
{ "_id" : 2, "name" : "Rock A Feller Bar and Grill", "violations" : 2 }
{ "_id" : 3, "name" : "Empire State Sub", "violations" : 5 }
{ "_id" : 4, "name" : "Pizza Rat's Pizzaria", "violations" : 8 }
想为每个文档更新特定字段,这些字段是
{ "_id" : 1, "name" : "Central Perk Cafe 1" }
{ "_id" : 2, "name" : "Rock A Feller Bar and Grill 2"}
{ "_id" : 3, "violations" : 7 }
{ "_id" : 4, "name" : "Pizza Rat", "violations" : 9 }
是否可以在单个请求中实现。我已经通过了update和updateMany方法。但是它会使用相同的字段集更新多个文档。