在 MongoDB 中,可以使用 $addFields 或 $rename 操作符来添加字段。

  • 使用 $addFields 操作符:
db.collection.updateMany({}, [{$addFields: {newField: "value"}}])

更多推荐