@entria/mongo-aggregate-lodash
v0.0.1
Published
This package will make you write aggregate in a more terse way much like lodash utilities
Downloads
4
Readme
Mongo Aggregate Lodash
This package will make you write aggregate in a more terse way much like lodash utilities
How to install
yarn add @entria/mongo-aggregate-lodash
Examples
- Without using
mongo-aggregate-lodash
{
$group: {
averageDividend: {
$sum: {
$multiply: ['$score', '$field.weight'],
}
},
averageDivisor: {
$sum: '$field.weight'
},
}
}
- Using
mongo-aggregate-lodash
import { sum, multiply } from '@entria/mongo-aggregate-lodash';
{
$group: {
averageDividend: sum(multiply('$score', '$field.weight')),
averageDivisor: sum('$field.weight'),
}
}