发布于 2015-09-14 15:03:54 | 170 次阅读 | 评论: 0 | 来源: 网络整理
也可以参考
1.4 新版功能.
The $elemMatch operator matches more than one component within an array element. For example,
db.collection.find( { array: { $elemMatch: { value1: 1, value2: { $gt: 1 } } } } );
returns all documents in collection where the array array satisfies all of the conditions in the $elemMatch expression, or where the value of value1 is 1 and the value of value2 is greater than 1. Matching arrays must have at least one element that matches all specified criteria. Therefore, the following document would not match the above query:
{ array: [ { value1:1, value2:0 }, { value1:2, value2:2 } ] }
while the following document would match this query:
{ array: [ { value1:1, value2:0 }, { value1:1, value2:2 } ] }