MongoDb Assignment
- Find all movies where:
- Runtime is greater than 150 minutes
db.movies.find({runtime:{$gt:150}},{title:true,_id:false})
- Rating is higher than 8.5
db.movies.find({runtime:{$gt:150}},{title:true,_id:false})
- Year is between 2000 and 2015 (inclusive)
db.movies.find({year:{$gt:2000,$lt:2015}},{title:true,_id:false})
- Box office earnings were less than 500 million OR greater than 1 billion
db.movies.find({$or:[{boxOffice:{$lt:500}},{boxOffice:{$gt:1000}}]},{title:true,_id:false})
- Find movies directed by Christopher Nolan that won an Oscar, made more than 700 million at box office, and are available on Netflix.
db.movies.find({$and:[{director:"Christopher Nolan"},{isOscarWinner:true},{boxOffice:{$gt:700}},{streamingOn:{$in:["Netflix"]}}]},{title:true,_id:false})
- Find movies that have special features, where both behind-the-scenes content and deleted scenes are available.
db.movies.find({"specialFeatures.behindTheScenes":true,"specialFeatures.deletedScenes":true},{title:true,_id:false})
- Find movies where either Carrie-Anne Moss or Morgan Freeman is in the cast, have language options available, and can be watched on at least 2 streaming platforms.
db.movies.find({ cast: { $in: ["Carrie-Anne Moss", "Morgan Freeman"] }, languages: { $exists: true, $not: { $size: 0 } }, streamingOn: { $exists: true, $not: { $size: 1 } }},{title:true,_id:false})
- For the movie "Inception", add Chinese to its languages.
db.movies.updateOne({title:"Inception"},{$push:{languages:"Chinese"}})
- Add Michael Caine to the cast of all Christopher Nolan movies.
db.movies.updateMany({director:{$in:["Christopher Nolan"]}},{$push:{cast:"MichaelĀ Caine"}})
- Add Disney+ as a streaming option for all movies longer than 140 minutes.
db.movies.updateMany({runtime:{$gt:140}},{$push:{streamingOn:"Disney+"}})
- Find movies that have exactly 2 genres and have box office earnings listed, but don't have any special features.
db.movies.find({genre:{$size:2},boxOffice:{$exists:true},specialFeatures:{$exists:false}},{title:true,_id:false})
- Remove all movies with rating less than 8.0.
db.movies.deleteMany({rating:{$lt:8}})
- Remove Netflix from the streaming platforms of all movies released before 2000.
db.movies.updateMany({year:{$lt:2000}},{$pull:{streamingOne:"Netflix"}})
- Find movies where box office earnings are more than 10 times the runtime.
- Find all movies available on exactly the same streaming platforms as "The Matrix".
db.movies.find({streamingOn:{$all:["Netflix","Amazon Prime"],$size:2}},{title:true,_id:false})
- Find movies that have both "Action" and "Sci-Fi" in their genres.
db.movies.find({genre:{$all:["Action","Sci-Fi"]}},{title:true,_id:false})
- Find movies where "Action" is the first genre listed.
- Find movies that have exactly 3 cast members.
db.movies.find({cast:{$size:3}})