Read Documents: Part 6
Learn to use projection operators.
We'll cover the following...
Projection operators
Projection means to select only the necessary data instead of the entire document. The projection operators are used to project the output of the query. The second argument of find
functions is a projection document, and we can only define projection operators inside it.
$
operator
The $
operator is called the positional operator, and it’s used to project the first array element from the document. Below are a few points to remember about the positional operator:
- It is applied only on the
array
field. - It works only if the
array
field is included in the filter query, otherwise, it throws an