The Query
object allows you to set the operators and values used to find the document to which you want to apply the database operations. These operators define this like “field values greater than a certain amount.” The operators all work off a path to the field; you can specify this path by using the where()
method or include it in the operator method. If no operator method is specified, the last path passed to a where()
method is used.
For example, the gt()
operator compares against the value
field:
query.where('value').gt(5)
However, in the statement below, the lt()
operator compares against the score
field:
query.where('value').gt(5).lt('score', 10);
Table 16.4 lists the most common methods that can be applied to the Query
object.