[mongodb] copying over other field values

Kepler·2021년 10월 27일
0
db.collection.updateMany(
    {},
  [{$set:{
    "new_field":[
      {
        "new_inner_field_1": "01-01",
        "new_inner_field_2":"$existing_field"
      }
    ]
  }}]
)

Note:

  • wrap $set with array,
  • $ in front of the name of the existing field
profile
🔰

0개의 댓글