2023-12-29

MongoDB - Remove a field from an array of documents

 db.collection_name.updateOne(

   {"array_of_docs.field_name": {$exists: 1}}, 

   {$unset: {"array_of_docs.$[].field_name": ""}}

);

No comments:

Post a Comment