Multiple $where queries in MongoDB

后端 未结 2 1023
南方客
南方客 2021-01-26 00:57

I tried to put following query together, but it is not working:

db.sss.find({
    \"pos\": { \"$gte\": 200000, \"$lt\": 2000000 },
    \"$where\": \"(this.chr.le         


        
2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-26 01:23

    I assume that you have a problem with your $where logic. The way you described it:

    (this.chr.letter != "X" && this.chr.no == 5) &&
    (this.chr.letter != "X" && this.chr.no == 6) &&
    (this.chr.letter != this.chr.letter)
    

    Will return you nothing because this.chr.no can no be 5 and 6 at the same time. Most probably you wanted to have || in between of your brackets.

提交回复
热议问题