Finding Documents
Finding Documents: Finding Documents with find and findOne, Comparison Operators: $gt, $lt, $in and More, Combining Conditions: $and, $or and $not, Missing…
Updated
- Finding Documents with find and findOne (Novice): A filter describes the documents you want, field by field; find gives back every document that matches, findOne the first one or null, and countDocuments how many there are.
- Comparison Operators: $gt, $lt, $in and More (Apprentice): Comparison operators let a filter ask for more than an exact value, such as less than 30 minutes, a range between two numbers, one of a list of cuisines, or anything but one value.
- Combining Conditions: $and, $or and $not (Apprentice): Two fields in one filter already mean "and"; $or matches when any of its conditions does, $and holds conditions that can't share one document, and $not and $nor rule documents out.
- Missing Fields, null and $exists (Apprentice): Documents in one collection don't all have the same fields; a filter for null matches a missing field too, $exists asks whether the field is there at all, and $type finds values stored as the wrong kind.