zoukankan      html  css  js  c++  java
  • MongoDb学习(四)--Repository----语法关键字

    表7.查询方法支持的关键字
    关键词样品逻辑结果

    After

    findByBirthdateAfter(Date date)

    {"birthdate" : {"$gt" : date}}

    GreaterThan

    findByAgeGreaterThan(int age)

    {"age" : {"$gt" : age}}

    GreaterThanEqual

    findByAgeGreaterThanEqual(int age)

    {"age" : {"$gte" : age}}

    Before

    findByBirthdateBefore(Date date)

    {"birthdate" : {"$lt" : date}}

    LessThan

    findByAgeLessThan(int age)

    {"age" : {"$lt" : age}}

    LessThanEqual

    findByAgeLessThanEqual(int age)

    {"age" : {"$lte" : age}}

    Between

    findByAgeBetween(int from, int to)

    {"age" : {"$gt" : from, "$lt" : to}}

    In

    findByAgeIn(Collection ages)

    {"age" : {"$in" : [ages…​]}}

    NotIn

    findByAgeNotIn(Collection ages)

    {"age" : {"$nin" : [ages…​]}}

    IsNotNull, NotNull

    findByFirstnameNotNull()

    {"firstname" : {"$ne" : null}}

    IsNull, Null

    findByFirstnameNull()

    {"firstname" : null}

    LikeStartingWithEndingWith

    findByFirstnameLike(String name)

    {"firstname" : name} (name as regex)

    NotLike, IsNotLike

    findByFirstnameNotLike(String name)

    {"firstname" : { "$not" : name }} (name as regex)

    Containing 在字符串上

    findByFirstnameContaining(String name)

    {"firstname" : name} (name as regex)

    NotContaining 在字符串上

    findByFirstnameNotContaining(String name)

    {"firstname" : { "$not" : name}} (name as regex)

    Containing 关于收藏

    findByAddressesContaining(Address address)

    {"addresses" : { "$in" : address}}

    NotContaining 关于收藏

    findByAddressesNotContaining(Address address)

    {"addresses" : { "$not" : { "$in" : address}}}

    Regex

    findByFirstnameRegex(String firstname)

    {"firstname" : {"$regex" : firstname }}

    (No keyword)

    findByFirstname(String name)

    {"firstname" : name}

    Not

    findByFirstnameNot(String name)

    {"firstname" : {"$ne" : name}}

    Near

    findByLocationNear(Point point)

    {"location" : {"$near" : [x,y]}}

    Near

    findByLocationNear(Point point, Distance max)

    {"location" : {"$near" : [x,y], "$maxDistance" : max}}

    Near

    findByLocationNear(Point point, Distance min, Distance max)

    {"location" : {"$near" : [x,y], "$minDistance" : min, "$maxDistance" : max}}

    Within

    findByLocationWithin(Circle circle)

    {"location" : {"$geoWithin" : {"$center" : [ [x, y], distance]}}}

    Within

    findByLocationWithin(Box box)

    {"location" : {"$geoWithin" : {"$box" : [ [x1, y1], x2, y2]}}}

    IsTrue, True

    findByActiveIsTrue()

    {"active" : true}

    IsFalse, False

    findByActiveIsFalse()

    {"active" : false}

    Exists

    findByLocationExists(boolean exists)

    {"location" : {"$exists" : exists }}

    一万年太久,只争朝夕!
  • 相关阅读:
    2.6 CMMI2级——供应商协议管理(Supplier Agreement Management)
    使用boch仿真器在x86 PC平台上搭建Linux0.11系统环境(windows下)
    java实现登录验证码
    Hadoop DBOutputFormat的使用
    史蒂芬·金《肖申克的救赎》读后感
    Change Base
    IOS深入学习(20)之Object modeling
    android对话框(Dialog)的使用方法
    郝萌主的微信公众号上线了
    Dell shareplex 与HVR数据复制软件
  • 原文地址:https://www.cnblogs.com/chaoba/p/10060443.html
Copyright © 2011-2022 走看看