Recall & Review
beginner
What does the
$or operator do in MongoDB queries?The
$or operator allows you to specify multiple conditions, and it returns documents that satisfy at least one of those conditions.Click to reveal answer
beginner
How do you structure a query using
$or in MongoDB?You use
$or with an array of condition objects. For example: { $or: [ { age: { $lt: 30 } }, { city: 'New York' } ] } finds documents where age is less than 30 OR city is New York.Click to reveal answer
intermediate
If a document matches multiple conditions inside
$or, how many times does it appear in the result?The document appears only once in the result, even if it matches multiple
$or conditions.Click to reveal answer
intermediate
Can
$or be combined with other operators in the same query?Yes,
$or can be combined with other operators like $and, $not, or direct field queries to build complex filters.Click to reveal answer
advanced
What happens if you use
$or with an empty array in MongoDB?Using
$or with an empty array returns no documents because there are no conditions to satisfy.Click to reveal answer
What does the MongoDB
$or operator require as its value?✗ Incorrect
The
$or operator requires an array of condition objects to check if any condition is true.If a document matches two conditions inside
$or, how many times will it appear in the query result?✗ Incorrect
Documents appear only once in the result even if they match multiple
$or conditions.Which of the following is a valid
$or query in MongoDB?✗ Incorrect
The
$or operator must have an array of condition objects as its value.What will happen if you run a query with
$or: []?✗ Incorrect
An empty array means no conditions to satisfy, so no documents are returned.
Can
$or be used together with $and in the same MongoDB query?✗ Incorrect
You can combine
$or and $and to create complex queries.Explain how the
$or operator works in MongoDB queries and give an example.Think about how you would find documents that meet one or more criteria.
You got /3 concepts.
Describe what happens if a document matches multiple conditions inside a
$or operator.Consider how query results avoid repetition.
You got /3 concepts.