MongoDB中關於查詢條件中包含集合中欄位的查詢,mongodb查詢條件

來源:互聯網
上載者:User

MongoDB中關於查詢條件中包含集合中欄位的查詢,mongodb查詢條件

要查詢的資料結構如下:

以查詢其中的versionLimitList欄位為例

MongoOperations工具類查詢相關語句

<pre name="code" class="java">Criteria criteria1 = Criteria.where("validStartTime").gt(new Date()).and("versionLimitList").elemMatch(Criteria.where("clientId").is(109).and("platFormCode").is(2);


查詢
validStartTime大於目前時間,並且versionLimitList欄位中的clientId屬性值為109和platFormCode屬性值為2

MongoVue中的語句

{    "validStartTime": {        "$gt": ISODate("2014-11-01T10:33:09.661Z")    },    "versionLimitList": {        "$elemMatch": {            "clientId": 109,            "platFormCode": 2        }    }}
對應實際執行的語句

db.systemInfo211.find({ "validStartTime" : { "$gt" : ISODate("2014-11-01T10:33:09.661Z") }, "versionLimitList" : { "$elemMatch" : { "clientId" : 109, "platFormCode" : 2 } } }).limit(50);
查詢結果如下



相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.