How to use aggregation in MongoDB
Link บทความ : ทดลองเขียน Aggregation ใน MongoDB
npm install
npm start
- A series of document transformations
- Executed in stages
$match
=>$project
=>$group
=>$sort
$match
: Filter documents$project
: Reshape documents (Include, exclude, rename fields)$group
: Summarize documents$sort
: Ordering documents$limit
: Paginate documents$skip
: Same as$limit
SELECT
=$project
WHERE
=$match
ORDER BY
=$sort
LIMIT
=$limit
Reference : SQL to Aggretation Mapping Chart