MongoDb Assignment

  1. Find all movies where:
    1. Runtime is greater than 150 minutes
    2. db.movies.find({runtime:{$gt:150}},{title:true,_id:false})
    3. Rating is higher than 8.5
    4. db.movies.find({runtime:{$gt:150}},{title:true,_id:false})
    5. Year is between 2000 and 2015 (inclusive)
    6. db.movies.find({year:{$gt:2000,$lt:2015}},{title:true,_id:false})
    7. Box office earnings were less than 500 million OR greater than 1 billion
    8. db.movies.find({$or:[{boxOffice:{$lt:500}},{boxOffice:{$gt:1000}}]},{title:true,_id:false})

  2. Find movies directed by Christopher Nolan that won an Oscar, made more than 700 million at box office, and are available on Netflix.
  3. db.movies.find({$and:[{director:"Christopher Nolan"},{isOscarWinner:true},{boxOffice:{$gt:700}},{streamingOn:{$in:["Netflix"]}}]},{title:true,_id:false})

  4. Find movies that have special features, where both behind-the-scenes content and deleted scenes are available.
  5. db.movies.find({"specialFeatures.behindTheScenes":true,"specialFeatures.deletedScenes":true},{title:true,_id:false})

  6. 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.
  7. 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})

  8. For the movie "Inception", add Chinese to its languages.
  9. db.movies.updateOne({title:"Inception"},{$push:{languages:"Chinese"}})

  10. Add Michael Caine to the cast of all Christopher Nolan movies.
  11. db.movies.updateMany({director:{$in:["Christopher Nolan"]}},{$push:{cast:"MichaelĀ Caine"}})

  12. Add Disney+ as a streaming option for all movies longer than 140 minutes.
  13. db.movies.updateMany({runtime:{$gt:140}},{$push:{streamingOn:"Disney+"}})

  14. Find movies that have exactly 2 genres and have box office earnings listed, but don't have any special features.
  15. db.movies.find({genre:{$size:2},boxOffice:{$exists:true},specialFeatures:{$exists:false}},{title:true,_id:false})

  16. Remove all movies with rating less than 8.0.
  17. db.movies.deleteMany({rating:{$lt:8}})

  18. Remove Netflix from the streaming platforms of all movies released before 2000.
  19. db.movies.updateMany({year:{$lt:2000}},{$pull:{streamingOne:"Netflix"}})

  20. Find movies where box office earnings are more than 10 times the runtime.


  21. Find all movies available on exactly the same streaming platforms as "The Matrix".
  22. db.movies.find({streamingOn:{$all:["Netflix","Amazon Prime"],$size:2}},{title:true,_id:false})

  23. Find movies that have both "Action" and "Sci-Fi" in their genres.
  24. db.movies.find({genre:{$all:["Action","Sci-Fi"]}},{title:true,_id:false})

  25. Find movies where "Action" is the first genre listed.


  26. Find movies that have exactly 3 cast members.
  27. db.movies.find({cast:{$size:3}})