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

Difference between revisions of "AGGREGATE Movie tutorial"

From NoSQLZoo
Jump to: navigation, search
Line 15: Line 15:
 
     }}
 
     }}
 
])
 
])
 +
</div>
 +
</div>
 +
 +
==John Hurt in Harry Potter==
 +
<div class=q data-lang="mongo">
 +
Use aggregate to show details of the movie "Alien"
 +
<pre class=def>
 +
</pre>
 +
<div class=ans>
 +
db.movies.aggregate([
 +
    {$match:{
 +
        cast:"John Hurt"
 +
    }},
 +
    {$match:{title:{$regex:'Harry Potter'}}},
 +
    {$project:{title:1,_id:0}}
 +
]).pretty()
 
</div>
 
</div>
 
</div>
 
</div>

Revision as of 22:15, 11 May 2017

Alien

Use aggregate to show details of the movie "Alien"

db.movies.aggregate([
    {$match:{
        title:"Alien"
    }}
])

db.movie.aggregate([

   {$match:{
       title:"Alien"
   }}

])

John Hurt in Harry Potter

Use aggregate to show details of the movie "Alien"


db.movies.aggregate([

   {$match:{
       cast:"John Hurt"
   }},
   {$match:{title:{$regex:'Harry Potter'}}},
   {$project:{title:1,_id:0}}

]).pretty()