mongodb queries both with AND and OR

后端 未结 4 1941
情歌与酒
情歌与酒 2020-12-13 00:10

can I use combination of OR and AND in mongodb queries?

the code below doesn\'t work as expected

db.things.find({
           $and:[
                {         


        
4条回答
  •  醉酒成梦
    2020-12-13 00:27

    Shorter to use an implicit AND operation:

    db.things.find({
        $or : [ 
            {"first_name": "john"},
            {"last_name": "john"}
        ],
        "phone": "12345678"         
    })
    

提交回复
热议问题