Below the dotted line in the preceding diagram, you will note a more complex form of stating the query. In the diagram, $op would represent one of the query operators (also referred to as query selectors) that are available in MongoDB.
Query operators fall into the following categories:
- Comparison ($eq, $gt, $gte, $in, $lt,$lte, $ne, $nin)
- Logical ($and, $not, $or, $nor)
- Element ($exists, $type)
- Evaluation ($expr, $jsonSchema, $mod, $regex, $text, $where)
- Geospatial ($geoIntersects, $geoWithin, $near, $nearSphere)
- Array ($all, $elemMatch, $size)
- Bitwise ($bitsAllClear, $bitsAllSet, $bitsAnyClear, $bitsAnySet)
- Comments ($comment)
As an example, let's say that the management wants a count of customers from non-English-speaking majority countries over the age of 50. The first thing we can do is create a JavaScript array variable of majority-English-speaking country codes. As a reference, we draw a list of countries from a document produced...