检查mongoDb集合中是否存在特定字段,不包括一条记录

检查mongoDb集合中是否存在特定字段,不包括一条记录,mongodb,database,Mongodb,Database,我有收集,如下所示 { "_id" : ObjectId("58fe3768f997ca09d551c34e"), "firstName" : "arbar", "lastName" : "ame", "email" : "test41@gmail.com", "phone" : "9966589965", "password" : "$2a$10$pgRWb8Db385A5BbicE

我有收集,如下所示

  { 
        "_id" : ObjectId("58fe3768f997ca09d551c34e"), 
        "firstName" : "arbar", 
        "lastName" : "ame", 
        "email" : "test41@gmail.com", 
        "phone" : "9966589965", 
        "password" : "$2a$10$pgRWb8Db385A5BbicEDJ2erHuUQsAIVmjqVuccXj7x.1iptdY/z7a", 
        "team_id" : ObjectId("58ef6d0a11c37915acaf7c9b"), 
        "activated" : false, 
        "accessLevel" : NumberInt(6)
    }
    { 
        "_id" : ObjectId("58fe37c2f997ca09d551c350"), 
        "firstName" : "Abrar Ahmed", 
        "lastName" : "asdf", 
        "email" : "test42@gmail.com", 
        "phone" : "9966158845", 
        "password" : "$2a$10$y3hPjuHeq0HVyukTnGCRT.k5xfSUH0z/mdGR8n7Gu09f7A7Z20bV6", 
        "team_id" : ObjectId("58ef6d0a11c37915acaf7c9b"), 
        "activated" : false, 
        "accessLevel" : NumberInt(6)
}
.
.
.
.
.
.
我正在检查电子邮件是否
test41@gmail.com如果我使用
this.collection.findOne({email:'test41@gmail.com' });
将查找集合中的所有记录,但如何通过使用_id字段作为排除的引用来排除集合中的一条记录

此处,电子邮件存在于集合的一个记录中
“_id”:ObjectId(“58fe3768f997ca09d551c34e”),
,但我想排除此记录并搜索集合中的其余记录

不要使用
findOne
,使用
find
查找所有出现的情况。现在,如果您想排除某些文档,您可以通过以下方法进行操作

db.collection.find({$and: [{"email": "test41@gmail.com"}}, {"_id": {$ne: ObjectId("58fe3768f997ca09d551c34e")}}]})
可能重复的