mongodb和关系数据库不一样,不可以直接使用"...Where 字段A=字段B"的方式来查找字段相同的条目。不过我们可以间接的实现,使用“$where”。No code you say a JB,废话不多说,直接贴代码:
db.foo.find({"$where":function(){
for(var current in this){
for(var other in this){
if(current != other && this[current] == this[other]){
return true;
}
}
}
return false;
}})

所有评论(0)