代码之家  ›  专栏  ›  技术社区  ›  Aquarius_Girl

MongoDB中何时应跳过$和运算符?

  •  0
  • Aquarius_Girl  · 技术社区  · 5 年前

    https://www.w3resource.com/mongodb-exercises/mongodb-exercise-12.php

    db.restaurants.find(
                               {
                                 "cuisine" : {$ne : "American "},
                                 "grades.score" :{$gt: 70},
                                 "address.coord" : {$lt : -65.754168}
                                }
                         );
    

    以下是这里提到的

    Note : Do this query without using $and operator.
    

    1 回复  |  直到 5 年前
        1
  •  1
  •   Gibbs    5 年前

    不,

    MongoDB中何时应跳过$和运算符?

    other than below cases

    1. Same Field ,那么唯一可以实现的选择就是使用 and
    2. Same Operator

    Refer

    A OR (B AND C) ,则需要使用 $or , $and

    如果你必须得到所有 American cushiness abc cushiness 具有 grades score address coord $and, $or

    上面提到的链接是一个练习,所以你可以用/不用 $和 .