w3resource

Find movies with "Short" genre


Find all movies with full information from the 'movies' collection that have "Short" genre.

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({ "genres": "Short" })

Output:

  {
    _id: ObjectId("573a1393f29313caabcdced3"),
plot: 'Disney animators tour South America and present four animated shorts inspired by their trip.',
genres: [ 'Animation', 'Short', 'Family' ],
runtime: 42,
rated: 'APPROVED',
cast: [ 'Fred Shields', 'Josè Oliveira' ],
num_mflix_comments: 1,
poster: 'https://m.media-amazon.com/images/M/MV5BYzQxZmRiMDgtNDg4ZS00ODE2LTlkZGMtYWNkZmE4ZjJjNzMzXkEyXkFqcGdeQXVyNDY2MTk1ODk@._V1_SY1000_SX677_AL_.jpg',
title: 'Saludos Amigos',
fullplot: `Live-action segments show members of the Disney staff touring South America and recording their impressions in sketches. These segue into four animated sections: "Lake Titicaca" depicts tourist Donald Duck's troubles with a stubborn llama; "Pedro" tells of a little mail plane's adventures flying over the treacherous Andes; "El Gaucho Goofy" transplants an American cowboy into the Argentine pampas; and in "Aquarela do Brasil," Jose Carioca shows Donald the sights and sounds of Rio de Janiero.`,
languages: [ 'English', 'Portuguese' ],
released: ISODate("1943-02-06T00:00:00.000Z"),
directors: [
      'Wilfred Jackson',
      'Jack Kinney',
      'Hamilton Luske',
      'Bill Roberts'
    ],
writers: [
      'Ted Sears (story)',
      'William Cottrell (story)',
      'Webb Smith (story)',
      'Homer Brightman (story)',
      'Ralph Wright (story)',
      'Roy Williams (story)',
      'Harry Reeves (story)',
      'Dick Huemer (story)',
      'Joe Grant (story)'
    ],
awards: {
wins: 4,
nominations: 0,
text: 'Nominated for 3 Oscars. Another 1 win.'
    },
lastupdated: '2015-09-01 00:32:26.647000000',
year: 1942,
imdb: { rating: 6.3, votes: 2558, id: 36326 },
countries: [ 'USA' ],
type: 'movie',
tomatoes: {
viewer: { rating: 3.1, numReviews: 2591, meter: 42 },
dvd: ISODate("2000-05-02T00:00:00.000Z"),
critic: { rating: 6.4, numReviews: 10, meter: 80 },
lastUpdated: ISODate("2015-08-30T20:10:54.000Z"),
consensus: "One of Disney's lesser-known animated films, Saludos Amigos may be slight stuff, but it's still a spirited, energetic travelogue.",
rotten: 2,
fresh: 8
    }
  }
.....

Explanation:

The said query in MongoDBretrieves all movies with full information from the 'movies' collection that have the "Short" genre.

In the find() method the query searches for movies where the "genres" field contains the value "Short".

Improve this sample solution and post your code through Disqus.

Previous: Find movies with runtime greater than 120 minutes.
Next: Retrieving movies directed by William K.L. Dickson.

What is the difficulty level of this exercise?



Follow us on Facebook and Twitter for latest update.