mongoDB 字段间操作的方法

来源:互联网 发布:手机淘宝软件删不掉 编辑:程序博客网 时间:2024/06/06 21:50


mongoDB 字段间操作需求使用javascript扩展的方式


reup = function(x){ 
     db.tb_1.update({_id: x._id}, {$set: {bb: x.aa*x.aa}});
}; 
db.tb_1.find().forEach(reup); 


结果