zoukankan      html  css  js  c++  java
  • mongodb中比较($lt $lte $gt $gte)查询条件说明

    $lt    <   (less  than )
    
    $lte    <=  (less than  or equal to )
    
    $gt   >    (greater  than )
    
    $gte   >=    (greater  than or   equal to)
    
     
    
    $ne  != (not equal to)不等于  {'age': {'$ne': 20}}
    
    $in  在范围内  {'age': {'$in': [20, 23]}}   注意用list
    
    $nin  (not in)  不在范围内{'age': {'$nin': [20, 23]}} 注意用list。这个方法可以计算某个值既不等于x也不等于y
    
    $regex (正则匹配) db.collection.find({'name': {'$regex': '^M.*'}})  匹配以M开头的名字
    
    $exists      属性是否存在       {'name': {'$exists': True}}     查找name属性存在
    
    $type     类型判断        {'age': {'$type': 'int'}}       age的类型为int
    
    $text      文本查询      {'$text': {'$search': 'Mike'}}     text类型的属性中包含Mike字符串
    
    $or  查找多种条件   ({'$or':[{'name':'chen'},{'name':'wang'}]})
    
     
    
    组合使用方法如下:
    
    db.user.find({"age":{"$gte":18,"$lte":25}})
    
     
    
    对于日期的条件查询方法:
    
    db.getCollection('news').find({'pub_date':{'$gte':'2017-07-11  11:0:0'}})
    
     
    
    2) 不等于 $ne
    
    例子:
    
    db.taobao.find( { age: { $ne : 10} } );
    ————————————————
    版权声明:本文为CSDN博主「西门大盗」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/xiongzaiabc/article/details/81186998
  • 相关阅读:
    postman一健导入swagger api所有接口
    pycharm 通过project interpreter国内镜像源设置
    Linux常用软件tree,autojump,lrzsz安装
    文献下载好用网站推荐
    SCIP,Clp,Gurobi和Cplex安装
    Linux下SuperLU安装
    【微服务理论】康威定律
    项目实战:动态系统的设计(类似朋友圈)
    认知提升:工作和薪资
    博客园美化 Cnblogs-Theme-SimpleMemory
  • 原文地址:https://www.cnblogs.com/lfyu/p/11961840.html
Copyright © 2011-2022 走看看