Posts

Showing posts from July, 2023

MongoDB Part2

  1.      Aggregations Exercise in MongoDB-I   AIM: To demonstrate Aggregations in MongoDB   THEORY : Aggregations operations process data records and return computed results. Aggregation operations group values from multiple documents together, and can perform a variety of operations on the grouped data to return a single result. MongoDB provides three ways to perform aggregation: the aggregation pipeline, the map-reduce function, and single purpose aggregation methods. Syntax  db.collection.aggregate(pipeline, options) Parameters Parameter Details 1.        pipeline array(A sequence of data aggregation operations or stages) 2.        options document(optional, available only if pipeline present as an array)     PROGRAM :   Example: Insert following documents in transcations collection >db.transactions.insert({ cr_dr : "D", amount : 100, fee : 2}); >db.transactions.insert({ cr_dr : "C", amount : 100, fee : 2}); >db.tra