Articles → MONGODB → $Out Aggregation Operator In Mongodb

$Out Aggregation Operator In Mongodb






Purpose





Example




Picture showing the sample document collection in mongodb




db.orders.aggregate([   
    {
        $group: {
            _id: "$customerId",
            firstOrderId: { $first: "$_id" }
        }
    },
   {
     $out: "total_costs"
   }
])


Picture showing the output of $out aggregation operator in mongodb



Output


Picture showing the records in the output collection



Posted By  -  Karan Gupta
 
Posted On  -  Thursday, June 13, 2024

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250