mongo-round
Helper function to perform rounding of numbers when working with mongoDB Aggregation Framework.
npm install mongo-round
Usage
var round = ;
To zero decimal places:
dbmyCollection;
To two decimal places:
dbmyCollection;
To cents and from cents - saves from rounding errors for armithmetic operations on financial data:
dbmyCollection;
Note that for negative numbers rounding is done using absolute values, which is fitting for financial data:
round(-0.5) will give -1