Aggregation Overview
415 views
Oct 24, 2024
Aggregation Overview Watch more Videos at https://www.tutorialspoint.com/videotutorials/index.htm Lecture By: Mr. Arnab Chakraborty, Tutorials Point India Private Limited
View Video Transcript
0:00
We are discussing another important concept in MongoDB, that is our aggregation overview
0:05
In case of aggregation, aggregation is nothing but one process which will take multiple
0:09
data and it will do some computation on the data and the result will be returned
0:15
So, now let us go for further discussion on this aggregation overview
0:20
So, what is aggregation in MongoDB? Aggregations, operations, process, data records and return the computed results
0:27
So multiple data will be taken and complete. results will be returned so aggregation operations group values from
0:35
multiple documents together and can perform a variety of operations on the group
0:41
data to return a single result as an example we can say some we can say
0:47
average we can say max we can say minimum so in this case what is happening we are
0:52
taking huge number of data and we are doing some competition and as a result
0:56
we are returning a single result and that is no as the aggregation here. So, aggregation operations group values from multiple documents
1:06
together. So, you know that this is our MongoDB is our document-oriented database. So
1:13
we'll be having the collections which is symbolizing the tables and documents are symbolizing
1:18
records. So it will take multiple documents, that means multiple records, and then can perform
1:25
a variety of operations on the group data Let it be addition let it be maximum calculations or minimum calculations or average calculations and on return it will return a single result The MongoDB has the method that is the aggregate method
1:40
The syntax of this method is db. .collection name, dot aggregate and then aggregate operation
1:50
So, db. .collection underscore name, that is a collection name. . aggregate that is an aggregate method and that is a aggregate operation
1:58
So, this is the syntax in which we can call this aggregate method to do the aggregation
2:05
So, here you can find we're having this dollar sum, we're having dollar AVG, dollar
2:09
mean, dollar max, dollar push, dollar first, dollar last. So these are the different expressions are there
2:17
So let us discuss the respective descriptions. So dollar sum from the name from this expression, it is quite obvious that what is the
2:24
purpose, add the field values of all the documents. Next, dollar average
2:31
So, finds the average for all the values of a field. Dollar mean
2:36
So, finds the minimum value of a field. Dollar max. So, from the very expression name, we are getting this idea, finds the maximum value
2:44
of a field. Dollar push, insert value to an array in the document
2:50
We're having dollar first. So get the first document from the collection
2:55
Dollar last, so get the last document from the collection. So, in the next video, we'll be going for one example of this aggregation
3:02
Please watch that one because that will be associated with some demonstration
3:06
Thanks for watching this video
#Programming