【Mongo】mongo更新字段为另一字段的值

更新字段为另一字段的值

db.postMongo.find(过滤条件).forEach(

   function(item){                 

       db.postMongo.update({"_id":item._id},{"$set":{"summary":item.content}},false,true) 

    }

)

db.postMongo.find({'summary':{$exists:false},'content':{$exists:1} }).forEach(
   function(item){                 
       db.postMongo.update({"_id":item._id},{"$set":{"summary":item.content}},false,true) 
    }
)


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29096438/viewspace-2212784/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29096438/viewspace-2212784/