where keyword with various operators to filter chosen documents from the final result-set.
These basic operators can be used with all value types, including 'numbers' and 'strings'.
For example, you can return every document from the Companies collection
whose field value = a given input.
where Name = 'The Big Cheese'
Filtering on nested properties is also supported.
So in order to return all companies from 'Albuquerque' we need to execute following query:
where Address.City = 'Albuquerque'
between returns results inclusively, and the type of border values used must match.
It works on both 'numbers' and 'strings' and can be substituted with the
where PricePerUnit between 10.5 and 13.0 // Using between
where PricePerUnit >= 10.5 and PricePerUnit <= 13.0 // Using >= and <=
in is validating if a given field contains passed values.
It will return results if a given field matches any of the passed values.
where Name in ('The Big Cheese', 'Unknown company name')
where Lines.ProductName in ('Chang', 'Spegesild', 'Unknown product name')
This operator checks if all passes values are matching a given field.
Due to its mechanics, it is only useful when used on array fields.
The following query will yield no results in contrast to the
where Lines.ProductName all in ('Chang', 'Spegesild', 'Unknown product name')
Removing 'Unknown product name' will return only orders that contain products with both
'Chang' and 'Spegesild' names.
where Lines.ProductName all in ('Chang', 'Spegesild')
Binary operators can be used to build more complex statements.
NOT operator can only be used with one of the other binary operators creating
OR NOT or
AND NOT ones.
where Name = 'The Big Cheese' OR Name = 'Richter Supermarkt'
where Freight > 500 AND ShippedAt > '1998-01-01'
where Freight > 500 AND ShippedAt > '1998-01-01' AND NOT Freight = 830.75
Subclauses can be used along with binary operators to build even more complex logical statements.