db.getCollection("t_ythgk_yjxxfkpz").find({"fkmc": {"$regex":","}}). forEach( function(item) { var tmp = []; var pjtmp = ""; tmp = item.fkmc.split(","); for(var k in tmp){ var fhmc = db.getCollection('t_ythgk_yjxxfkpz').findOne({"fkzd":tmp[k]},{"fkzd":1}); if(fhmc!=null){ print("====="+fhmc.fkzd); pjtmp = pjtmp + fhmc.fkzd + ","; } } print("打印获得的值:"+pjtmp); var zddmm = pjtmp; item.zddm = pjtmp.substr(0,pjtmp.length-1); print("打印获得的值========:"+item.zddm); db.getCollection('t_ythgk_yjxxfkpz').save(item); //print(item.zddm); } );
菜鸟程序媛,若有需修正之处,望指正~
WeChat/QQ:2463105280
【顺便说一下湖南有需要报考学历、证件的可以咨询我,保证毕业拿证,学信网可查学籍!给娃赚点尿不湿~】