mongodb搜索两个字段值相同的记录

db.re_local_stars.update({$where:function(){
	for(var current in this){
	   for(var other in this){
	     if(current != other && this["name"] == this["cname"]){
	       return true;
	     }
	   }
	 }
	 return false;	
}},{$set:{country:"xxx"}},{
     multi: true,
   })
db.re_local_stars.update({$where:function(){
	for(var current in this){
	   for(var other in this){
	     if(current != other && this["name"] == this["cname"]){
	       return false;
	     }
	   }
	 }
	 return true;	
}},{$set:{country:"xxx"}},{
     multi: true,
   })   
发布了64 篇原创文章 · 获赞 26 · 访问量 36万+

猜你喜欢

转载自blog.csdn.net/moliyiran/article/details/104099213