Hello.
The aggregation query is a pipeline - at each stage documents are passed, processed and forwarded to the next stage. So, you can apply the stage’s funtionality and see the result of that stage immediately. This can be observed clearly in the MongoDB Compass’s Aggregation Builder.
About the find with similar looking query options:
db.solarSystem.find({},{name:1,_id:0})
.skip(1)
.limit(2)
.sort({name:1})
The find method returns a cursor. And you are applying the skip, limit and sort cursor methods. The behavior of these methods is quite different from that of the similar sounding aggregation stages.
The cursor is a pointer (an interface) to the data of the result set on the database server. You get the cursor on the client (e.g., mongo shell) from where you submitted the query.
And, you must apply skip, limit and sort to the cursor before retrieving any documents from the database. Also, no matter in what order you apply these three methods the result will be same.
db.solarSystem.find({},{name:1,_id:0})
.skip(1)
.limit(2)
.sort({name:1})
.count()
The count returns the cursor’s original value before applying the skip and limit operations. To get the actual count you need to use the size method (and this would be 2 for the above query). The size method calculates the count after applying the limit and skip operations on the cursor. There is also a itcount method which gives the result as 2.
Please refer documentation for more details: