zoukankan      html  css  js  c++  java
  • mongodb一个关键字对多个字段同时查询,mongodb $or $and查询

    $query = '{ "$and": [

                    {"$or": [{"reported": {"$exists": false}}, {"reported": 0}]}, 
                    {"$or": [{"hidden": {"$exists": false}}, {"hidden":1}]}
              ]
              ,"_id":1081
           }';
    db->Post->find($query);
     
    该语句的查询意思是: 查找Post 文档 _id 为 1081 且 reported 字段不存在 或者 reported 字段为 0 或者 hidden 字段不存在 或者 hidden 字段为 0 的数据
     
    参考文档:http://denghai260.blog.163.com/blog/static/72686409201243043030422/
     
    db.inventory.find( { price:1.99, $or: [ { qty: { $lt: 20 } }, { sale: true } ] } )
    http://docs.mongodb.org/manual/reference/operator/query/or/
  • 相关阅读:
    flask之Blueprint蓝图
    flask之Flask、config配置
    flask之路由route
    flask之request
    flask之response
    pyhton中的深浅copy
    jQuery选择器
    Html常用标签
    python中的字典dict
    python基础知识
  • 原文地址:https://www.cnblogs.com/laifu/p/3635298.html
Copyright © 2011-2022 走看看