Cookies help us deliver our services. By using our services, you agree to our use of cookies. More information

Difference between revisions of "AGGREGATE Movies Tutorial"

From NoSQLZoo
Jump to: navigation, search
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.movie.aggregate([
+
db.movies.aggregate([
 
     {$match:{
 
     {$match:{
 
         title:'Alien'
 
         title:'Alien'
Line 29: Line 29:
 
]).pretty()
 
]).pretty()
 
</pre>
 
</pre>
<pre class=ans>db.world.aggregate([
+
<pre class=ans>db.movies.aggregate([
 
     {$match:{
 
     {$match:{
 
         title:'Casablanca'
 
         title:'Casablanca'

Revision as of 23:29, 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.movies.aggregate([
    {$match:{
        title:'Alien'
    }},
]).pretty()
db.movies.aggregate([
    {$match:{
        title:'Casablanca'
    }}
]).pretty()