Node.js 在NodeJs中使用$not GET undefined的mongodb

Node.js 在NodeJs中使用$not GET undefined的mongodb,node.js,mongodb,mongoose,Node.js,Mongodb,Mongoose,我试图在Mongo中使用$not生成一个find命令,正如我在本文中看到的 但是,我得到了未定义的。 我认为问题出在$not上,因为当我删除它并使用这样的命令时,它会工作 await Match.find( { type:"Friendly", status:"Pending", "date.fullDate":{$gt: date}, $or: [{"team1.players":{$elemMatch: {_id:playerId}}}

我试图在Mongo中使用
$not
生成一个find命令,正如我在本文中看到的

但是,我得到了
未定义的
。
我认为问题出在
$not
上,因为当我删除它并使用这样的命令时,它会工作

await Match.find(
        {
          type:"Friendly", status:"Pending", "date.fullDate":{$gt: date},
          $or: [{"team1.players":{$elemMatch: {_id:playerId}}}, {"team2.players":{$elemMatch: {_id:playerId}}}]
        }).sort({'date.fullDate':1}).exec(function(err, doc) {
          console.log(doc)
        return res.send({data: doc});
        });
注意:team2在文档中可能为空。 知道我为什么得到这个未定义的
吗。
我的文档如下所示:

match:{
  team1:{
    players:[
              _id:value,
              otherfields...
    ]
  },
  team2:{
    players:[
              _id:value,
              otherfields...
    ]
  }
}


我不得不使用
$nor
而不是
$not:{$or:[]}

类似的问题

match:{
  team1:{
    players:[
              _id:value,
              otherfields...
    ]
  },
  team2:{
    players:[
              _id:value,
              otherfields...
    ]
  }
}

await Match.find({
    type: "Friendly", status: "Pending", "date.fullDate": { $gt: date },
    $or: [
        {
            $not: {
                "team1.players": { $elemMatch: { _id: playerId } }
            }
        },
        {
            $not: {
                "team2.players": { $elemMatch: { _id: playerId } }
            }
        }
    ]
}).sort({ 'date.fullDate': 1 }).exec(function (err, doc) {
    console.log(doc)
    return res.send({ data: doc });
});