MongoDB - $elemMatch (array of embedded document query matching)

Create data

If you want to inquire, people with a math score of 80 or more find that the result is not what we want

The default query rule, as long as there is an element in the array that satisfies a given condition, then the record will be matched successfully

 

 

Using elemMatch, the query indicates that there is at least one element in the array that meets all the given conditions, that is, a record is found, there is a math score, and the math score is above 80

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324983480&siteId=291194637