Actions

AGGREGATE Movies Tutorial: Difference between revisions

From NoSQLZoo

Line 23: Line 23:
Show the details of the movie Casablanca
Show the details of the movie Casablanca
<pre class=def>
<pre class=def>
db.world.aggregate([
db.movie.aggregate([
     {$match:{
     {$match:{
         title:'Casablanca'
         title:'Alien'
     }},
     }},
])
]).pretty()
</pre>
</pre>
<pre class=ans>db.world.aggregate([
<pre class=ans>db.world.aggregate([
Line 33: Line 33:
         title:'Casablanca'
         title:'Casablanca'
     }}
     }}
])
]).pretty()
</pre>
</pre>
</div>
</div>

Revision as of 23:28, 14 October 2016

Investigating the Movie Database

The movie database includes thousands of movies with documents such as:

{
	"_id" : 10522,
	"title" : "Alien",
	"yr" : 1979,
	"director" : "Ridley Scott",
	"budget" : 11000000,
	"gross" : 104931801,
	"cast" : [
		"Tom Skerritt",
		"Sigourney Weaver",
		"Veronica Cartwright",
		"Harry Dean Stanton",
		"John Hurt",
		"Ian Holm",
		"Yaphet Kotto"
	]
}

Casablanca

Show the details of the movie Casablanca

db.movie.aggregate([
    {$match:{
        title:'Alien'
    }},
]).pretty()
db.world.aggregate([
    {$match:{
        title:'Casablanca'
    }}
]).pretty()
  • You have been served by: dill