Aggregate Mongodb Example


Example 1: how to write the aggragation in mongodb

> db.mycol.aggregate([{$group : {_id : "$by_user", num_tutorial : {$sum : 1}}}]) { "_id" : "tutorials point", "num_tutorial" : 2 } { "_id" : "Neo4j", "num_tutorial" : 1 } >

Example 2: MONGODB AGGREGATION tutorials

db.stocks.aggregate([   { $match: { "price": 2000 } } ])

Example 3: MONGODB AGGREGATION tutorials

db.stocks.insertMany([    { name: "Infosys", qty: 100, price: 800 },    { name: "TCS", qty: 100, price: 2000 },    { name: "Wipro", qty: 2500, price: 300 } ])

Example 4: MONGODB AGGREGATION tutorials

db.stocks.find().pretty()

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable