Home > Database > Mysql Tutorial > MongoDB中关于查询条件中包含集合中字段的查询

MongoDB中关于查询条件中包含集合中字段的查询

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 16:10:06
Original
2401 people have browsed it

要查询的数据结构如下: 以查询其中的versionLimitList字段为例 MongoOperations工具类查询相关语句 pre name=code class=javaCriteria criteria1 = Criteria.where(validStartTime).gt(new Date()).and(versionLimitList).elemMatch(Criteria.where(clientI

要查询的数据结构如下:

\

以查询其中的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);
Copy after login
Copy after login
查询validStartTime大于当前时间,并且versionLimitList字段中的clientId属性值为109和platFormCode属性值为2

MongoVue中的语句

{
    "validStartTime": {
        "$gt": ISODate("2014-11-01T10:33:09.661Z")
    },
    "versionLimitList": {
        "$elemMatch": {
            "clientId": 109,
            "platFormCode": 2
        }
    }
}
Copy after login
对应实际执行的语句
db.systemInfo211.find({ "validStartTime" : { "$gt" : ISODate("2014-11-01T10:33:09.661Z") }, 
"versionLimitList" : { "$elemMatch" : { "clientId" : 109, "platFormCode" : 2 } } }).limit(50);
Copy after login
查询结果如下

\

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
mongodb start
From 1970-01-01 08:00:00
0
0
0
linux - ubuntu14 error installing mongodb
From 1970-01-01 08:00:00
0
0
0
Use of symfony2 mongodb
From 1970-01-01 08:00:00
0
0
0
mongodb _id rename
From 1970-01-01 08:00:00
0
0
0
Parameter understanding of mongodb
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template