How to search using the elem match on the sub-document array? I ReportCollection called document with elements such as: -
/ * 0 * / { "_ id": ObjectId ( "5507bfc435e9470c9aaaa2ac"), "boss": ObjectId ( "5507bfc31e14d78e177ceebd ")," report ": {" XReport ": [{" name ":" XReport "" parameters ": {" X ": {" dateTime ":" 2015-03-11T18: 30: 00.000Z "," unit "1" value ": 102}}," createdBy ": ObjectId (" 5507bfc31e14d78e177ceebd ")," modifiedBy ": ObjectId (" 5507bfc31e14d78e177ceebd ")," _ id ": ObjectId (" 5507bfc41e14d78e177ceebf ")}]}} < / Code> I have been identified as reports.xReport [] ._ Search Parameter
Failure to have my following attempts: -
db.reports.find ({{Owner: ObjectId ( "5507afd3d54bae3513c185cb")}, { 'reports.xReport': {$ elemMatch: {_ id: objecti d ( "5507afd3d54bae3513c185cd") }}}}) in
it seems that you are trying to "launch" the To do the work you should do in the query. Rather your statement should look like this:
db.reports.find ({"owner": object ID ("5507bfc31e14d78e177ceebd"), "reports XReport ._id ": ObjectId (" 5507bfc41e14d78e177ceebf ")}, {" reports.xReport. $ ": 1}) then matches the" query "array status and" Launch "uses only that position in the match.
Also keep in mind that you never need to match with an area only when many fields are required in the condition, you use it to match the specific "element" Need to do
with the same token, which should be in the "query" statement instead.
The projected form can not be used with dot-document areas through point notation.
No comments:
Post a Comment