|Available Properties||Available Functions|
- Do not use global variables.
- In general, you should use
$whereonly when you can’t express your query using another operator. If you must use
$where, try to include at least one other standard query operator to filter the result set. Using
$wherealone requires a collection scan.
Using normal non-
$where query statements provides the following performance advantages:
Consider the following documents in the
The following example uses
$where and the
name field to an MD5 hash and returns any matching document.
The operation returns the following result: