The query conditions in MongoDB include fields in the collection.

Source: Internet
Author: User

The query conditions in MongoDB include fields in the collection.

The data structure to be queried is as follows:

Take the versionLimitList field as an example.

MongoOperations tool-related query statements

<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);

 
Query 
ValidStartTime is later than the current time, And the clientId attribute value in the versionLimitList field is 109 and the platFormCode attribute value is 2 

Statement in explain vue

{    "validStartTime": {        "$gt": ISODate("2014-11-01T10:33:09.661Z")    },    "versionLimitList": {        "$elemMatch": {            "clientId": 109,            "platFormCode": 2        }    }}
Corresponding to the actually executed statement

db.systemInfo211.find({ "validStartTime" : { "$gt" : ISODate("2014-11-01T10:33:09.661Z") }, "versionLimitList" : { "$elemMatch" : { "clientId" : 109, "platFormCode" : 2 } } }).limit(50);
The query result is as follows:



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.