74.6k views
4 votes
Write a query to find movies which either tomato meter is greater than 95 or imbd rating is greater than or equal to 9.5.

(NOTE: both meter and rating are embedded documents within tomato and imbd documents, respectively)

1 Answer

5 votes

Final answer:

To find movies which either Tomato Meter is greater than 95 or IMDb rating is greater than or equal to 9.5, use the MongoDB query provided.

Step-by-step explanation:

To find movies which either Tomato Meter is greater than 95 or IMDb rating is greater than or equal to 9.5, you can use the MongoDB query:

{
$or: [
{ 'tomato.meter': { $gt: 95 } },
{ 'imdb.rating': { $gte: 9.5 } }
]
}

This query uses the MongoDB $or operator to specify that either the 'tomato.meter' field is greater than 95 or the 'imdb.rating' field is greater than or equal to 9.5. The $gt and $gte operators are used to perform numerical comparisons on embedded document fields.

User Rylan Schaeffer
by
8.4k points