Suppose I have:
Order: {_id: ..., items: [...]}
How to filter orders which have item number greater than 5?
To see if the length is greater than 5, you can test if a 6th element exists:
db.orders.find({"items.6": {$exists: true}})
This is much more efficient than using $where.
$where