athiwatp / mongo-aggregate-example

How to use aggregation in MongoDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mongo-aggregate-example

How to use aggregation in MongoDB

Link บทความ : ทดลองเขียน Aggregation ใน MongoDB

Datasheet

Usage

npm install
npm start

What is Aggregation Pipeline?

  • A series of document transformations
  • Executed in stages
  • $match => $project => $group => $sort

Operators

  • $match : Filter documents
  • $project : Reshape documents (Include, exclude, rename fields)
  • $group : Summarize documents
  • $sort : Ordering documents
  • $limit : Paginate documents
  • $skip : Same as $limit

SQL to Aggregation Mapping

  • SELECT = $project
  • WHERE = $match
  • ORDER BY = $sort
  • LIMIT = $limit

Reference : SQL to Aggretation Mapping Chart

About

How to use aggregation in MongoDB

License:MIT License


Languages

Language:JavaScript 100.0%