Retrieve movies with complete information and "UNRATED" rating
Retrieve all movies from the 'movies' collection that have complete information and are rated as "UNRATED".
Structure of 'movies' collection:
{ _id: ObjectId("573a1390f29313caabcd42e8"), plot: 'A group of bandits stage a brazen train hold-up, only to find a determined posse hot on their heels.', genres: [ 'Short', 'Western' ], runtime: 11, cast: [ 'A.C. Abadie', "Gilbert M. 'Broncho Billy' Anderson", 'George Barnes', 'Justus D. Barnes' ], poster: 'https://m.media-amazon.com/images/M/MV5BMTU3NjE5NzYtYTYyNS00MDVmLWIwYjgtMmYwYWIxZDYyNzU2XkEyXkFqcGdeQXVyNzQzNzQxNzI@._V1_SY1000_SX677_AL_.jpg', title: 'The Great Train Robbery', fullplot: "Among the earliest existing films in American cinema - notable as the first film that presented a narrative story to tell - it depicts a group of cowboy outlaws who hold up a train and rob the passengers. They are then pursued by a Sheriff's posse. Several scenes have color included - all hand tinted.", languages: [ 'English' ], released: ISODate("1903-12-01T00:00:00.000Z"), directors: [ 'Edwin S. Porter' ], rated: 'TV-G', awards: { wins: 1, nominations: 0, text: '1 win.' }, lastupdated: '2015-08-13 00:27:59.177000000', year: 1903, imdb: { rating: 7.4, votes: 9847, id: 439 }, countries: [ 'USA' ], type: 'movie', tomatoes: { viewer: { rating: 3.7, numReviews: 2559, meter: 75 }, fresh: 6, critic: { rating: 7.6, numReviews: 6, meter: 100 }, rotten: 0, lastUpdated: ISODate("2015-08-08T19:16:10.000Z") } .....
Query:
db.movies.find({ rated: "UNRATED" })
Output:
{ _id: ObjectId("573a1391f29313caabcd8acf"), plot: "A traveller arrives at the Usher mansion to find that the sibling inhabitants, Roderick and Madeline Usher, are living under a mysterious family curse: Roderick's senses have become ...", genres: [ 'Short', 'Horror' ], runtime: 13, rated: 'UNRATED', cast: [ 'Herbert Stern', 'Hildegarde Watson', 'Melville Webber' ], title: 'The Fall of the House of Usher', fullplot: "A traveller arrives at the Usher mansion to find that the sibling inhabitants, Roderick and Madeline Usher, are living under a mysterious family curse: Roderick's senses have become painfully acute, while Madeline has become nearly catatonic. As the visitor's stay at the mansion continues, the effects of the curse reach their terrifying climax.", countries: [ 'USA' ], released: ISODate("2011-09-20T00:00:00.000Z"), directors: [ 'James Sibley Watson', 'Melville Webber' ], writers: [ 'Edgar Allan Poe (story)' ], awards: { wins: 1, nominations: 0, text: '1 win.' }, lastupdated: '2015-07-04 00:36:23.880000000', year: 1928, imdb: { rating: 7, votes: 820, id: 18873 }, type: 'movie', tomatoes: { viewer: { rating: 3.6, numReviews: 41, meter: 100 }, dvd: ISODate("2006-02-07T00:00:00.000Z"), lastUpdated: ISODate("2015-08-19T19:00:46.000Z") } },
Explanation:
The said query in MongoDBretrieves movies from the 'movies' collection that have complete information and are rated as "UNRATED".
The find() method filters documents where the value of the 'rated' field is equal to "UNRATED".
Improve this sample solution and post your code through Disqus.
Previous: Movies released in the USA.
Next: Retrieve movies with complete information and more than 1000 IMDb votes.
What is the difficulty level of this exercise?
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/mongodb-exercises/mongodb-movies-collection-exercise-6.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics