Skip to content

woovibr/mongo-aggregate-lodash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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'),
  }
}

About

Mongo aggregate helpers similar to lodash utilities

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published