Skip to content

Instantly share code, notes, and snippets.

View Deeptiman's full-sized avatar
:octocat:
Open Source

Deeptiman Pattnaik Deeptiman

:octocat:
Open Source
View GitHub Profile
[
{
"_id": "573a1390f29313caabcd6223",
"comments": [
{
"_id": "5a9427648b0beebeb69579cc",
"comment": "Rem officiis eaque repellendus amet eos doloribus. Porro dolor voluptatum voluptates neque culpa molestias. Voluptate unde nulla temporibus ullam.",
"date": "2012-03-26T05:30:00+05:30",
"email": "andrea_le@fakegmail.com",
"movie_id": "573a1390f29313caabcd6223",
[
{
"_id": "573a1390f29313caabcd6223",
"comments": [
{
"_id": "5a9427648b0beebeb69579cc",
"comment": "Rem officiis eaque repellendus amet eos doloribus. Porro dolor voluptatum voluptates neque culpa molestias. Voluptate unde nulla temporibus ullam.",
"date": "2012-03-26T05:30:00+05:30",
"email": "andrea_le@fakegmail.com",
"movie_id": "573a1390f29313caabcd6223",
{
$lookup:
{
from: <collection to join>,
localField: <field from the input documents>,
foreignField: <field from the documents of the "from" collection>,
as: <output array field>
}
}
{
"_id" : "total_vote",
"vote_count" : NumberInt(271026594)
}
db.movies.aggregate(
// Pipeline
[
// Stage 1
{
$match: {
// conditional query
"imdb.rating": {
$lt: 7.5
}
{
"_id" : 1.0,
"value" : 271026594.0
}
db.movies.mapReduce(
// map
function(){
emit(1,this.imdb.votes);
},
// reduce
function(key,vals){
var count = 0;
vals.forEach(function(v) {
[{
"email" : "andrea_le@fakegmail.com",
"name" : "Andrea Le"
},
{
"email" : "anthony_cline@fakegmail.com",
"name" : "Anthony Cline"
},
{
"email" : "emily_ellis@fakegmail.com",
db.user_data_list.find({})