几种可能存在的实体类型
public class AAA{ public List<Common> CommonList{get;set;} } public class BBB{ public Common CommonOne{get;set;} } public class Common{ public string Domain{get;set;} }
一、删除Mongo中指定字段

db.getCollection('AAA').find( {"CommonList.Domain": { $exists: true } } ).forEach(function(item){ var list = item.AttachList; list.forEach(function(attach){ if(attach.hasOwnProperty("Domain")){ delete attach.Domain } }) db.getCollection('AAA').update({"_id": item._id},{$set: {"CommonList": list}}); })

db.getCollection('BBB').update({"CommonOne.Domain": { $exists: true } },{$unset:{"CommonOne.Domain":""}},
二、修改Mongo中数据

db.getCollection('AAA').find({"CommonList":{$size:9},"IsActive":true}).forEach(function(item){ var photos = item.CommonList; photos.forEach(function(photo){ photo.Domain = "要修改的数据"; }) db.getCollection('AAA').update({"_id": item._id},{$set: {"CommonList": photos}}); })