Harsh choudhary - IT6A - 2203031080132

Assiement 1 - MongoDb

  1. Find all movies where:

    1. Runtime is greater than 150 minutes

       db.movies.find({runtime:{$gt:150}},{title:true,_id:0})
                              
    2. Rating is higher than 8.5

      db.movies.find({rating:{$gt:8.5}},{title:true,_id:0})
    3. Year is between 2000 and 2015 (inclusive)

      db.movies.find({year:{$gt:2000,$lt:2015}},{title:true,_id:0})
                              
    4. Box office earnings were less than 500 million OR greater than 1 billion

       db.movies.find({boxOffice:{$gt:500,$lt:1000}},{title:true,_id:0})
                              
  2. 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({director:"Christopher Nolan",isOscarWinner:true,boxOffice:{$gt:700},streamingOn:{$in:["Netflix"]}},{title:true,_id:0})
                      
                    
  3. Find movies that have special features, where both behind-the-scenes content and deleted scen

    db.movies.find({"specialFeatures.behindTheScenes":true,"specialFeatures.deletedScenes":true},{title:true,_id:false})
                    
  4. 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:1,_id:0})
                    
  5. For the movie "Inception", add Chinese to its languages.

    db.movies.updateOne({title:"Inception"},{$push:{language:"Chinese"}})
  6. Add Michael Caine to the cast of all Christopher Nolan movies.

     db.movies.updateMany({director:"Christopher Nolan"},{$addToSet:{cast:"Michael Caine"}})
                
  7. Add Disney+ as a streaming option for all movies longer than 140 minutes.

    db.movies.updateMany({runtime:{$gt:140}},{$addToSet:{streamingOn:"Disney+"}})
                
  8. Find movies that have exactly 2 genres and have box office earnings listed, but don't have any special features.

     db.movies.find({$and:[{genre:{$size:2}},{boxOffice:{$exists:true}},{specialFeatures:{$exists:false}}]})
  9. Remove all movies with rating less than 8.0.

    db.movies.deleteMany({ rating: { $lt: 8.0}});
  10. Remove Netflix from the streaming platforms of all movies released before 2000.

     db.movies.updateMany({ year: { $lt: 2000 }, streamingOn: "Netflix" }, { $pull: { streamingOn:"Netflix"}});
  11. Find movies where box office earnings are more than 10 times the runtime.

     db.movies.find({$expr:{ $gt: ["$boxOffice", { $multiply: ["$runtime",10]}]}})
                
  12. Find movies that have both "Action" and "Sci-Fi" in their genres.

    db.movies.find({ genre: { $all: ["Action", "Sci-Fi"]}});
  13. Find movies where "Action" is the first genre listed.

     db.movies.find({ genre: { $all: ["Action", "Sci-Fi"]}});
  14. Find movies that have exactly 3 cast members.

    db.movies.find({cast:{$size:3}});