0
    [
      {
        "_id": {
          "$oid": "628f4d39a498sc8sbf223cb58cvcb62"
        },
        "userId": "6284969f4dfv5sf4922cv95e78dbe",
        "siteId": "628f494896ec5df1adv0994fb611",
        "siteName": "Dream village",
        "role": "Owner",
        "blockId": "A - 1200",
        `**"Status": "Invited"**`, //update Status as Active
        "__v": 0
      },
  {
    "_id": {
      "$oid": "628f4d39a49bf2csjnjsvd23cb58cb62"
    },
    "userId": "6284969f4dffdf4jsdn92295e78dbe",
    "siteId": "628f494896effd1sjad0994fb611",
    "siteName": "Dream village",
    "role": "Owner",
    "blockId": "A - 1101",
    "Status": "Invited", //update Status as Active
    "__v": 0
  }
    ]

how to update this array of documents. I just want to update "Status": "Invited" to "Status": "Active" in all documents.

1 Answers1

0

If you want update all doc:

db.collection.updateMany( {}, { $set : { Status: 'Active' } } )

or update with filter:

db.collection.updateMany( <filter> , { $set : { Status: 'Active' } })

Detail at docs: https://www.mongodb.com/docs/manual/reference/method/db.collection.updateMany

VMT
  • 789
  • 1
  • 3
  • 11