mongodb update拼接多字段

db.collection.find({"_id" : ObjectId("5d60ac1366aadbbbfdec8b7a")}).forEach(function(item){ db.collention.update( {"_id":item._id}, { $set : { "tasktypeIds" : item.mainTasktypeId + "_" + item.subTasktypeId + "_" + item.subRelTasktypeId }} )})

 

描述:将tasktypeIds字段值更新为mainTasktypeId  ,subTasktypeId , subRelTasktypeId三个字段用下划线拼接而成的新值

你可能感兴趣的:(mongodb)