MongoDB - Aggregation Framework – Tasks and Exercise

Let us see some tasks with respect to aggregation framework.

  • Get count by status from orders
  • Get revenue for each order_item_order_id from orderItems
  • Get revenue for given order_item_order_id from orderItems

Let us take care of one exercise where we can use $project and compute bonus amount.

  • We want to give a 10% bonus for all employees. Get the bonus amount with employee id. Bonus can be computed by multiplying bonus percentage (10%) with salary. (hint: Use aggregate function with the project and multiply).