📜  通过添加一个名为“contact”的子文档来更新所有文档,其中包含一个键值、“email”:“name@gov.ph”和“phone”:“1234567”——无论代码示例

📅  最后修改于: 2022-03-11 14:57:59.853000             🧑  作者: Mango

代码示例1
db.employees.updateMany(`

{id: 1},{$push: {"contact": {"email": "steve.badiola.gov.ph", "phone": "+1 1234567"}}},

{id: 2},{$push: {"contact": {"email": "jamir.garcia.gov.ph", "phone": "+2 1234567"}}},

{id: 3},{$push: {"contact": {"email": "reg.rubio.gov.ph", "phone": "+3 1234567"}}},

{id: 4},{$push: {"contact": {"email": "ian.tayao.gov.ph", "phone": "+4 1234567"}}})