mongodb中如果使用两个$or查询,如下方式是错误的

{
 $or : [{ "creatorId" : 1888 }, { "workerId" : 1888 }, { "guardianId" : 1888 }]
,$or:[{jobName: "19100901"},{jobAreaName: "xx"}]
}

正确的使用方式有两种

1、使用显式$and,如下

{ $and: [
 {$or : [{ "creatorId" : 1888 }, { "workerId" : 1888 }, { "guardianId" : 1888 }]}
,{$or:[{jobName: "19100901"},{jobAreaName: "xx"}]}
]}

可以看出,使用两个$or时,必须使用显式的$and

相关文章:

  • 2022-12-23
  • 2021-07-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-26
猜你喜欢
  • 2022-12-23
  • 2021-08-30
  • 2022-12-23
  • 2022-12-23
  • 2021-09-27
  • 2021-11-20
  • 2021-10-04
相关资源
相似解决方案