thesebas / php-mongodb-helpers
There is no license information available for the latest version (v0.0.4) of this package.
MongoDB php helpers to build queries
v0.0.4
2017-08-29 22:21 UTC
Requires
- php: ^5.6|^7.0
Requires (Dev)
- phpunit/phpunit: ^5.0|^6.0
- satooshi/php-coveralls: ^1.0
This package is auto-updated.
Last update: 2025-02-25 11:11:15 UTC
README
MongoDB php helpers to build queries.
Write this:
$collection->aggregate([ project([ 'field' => reduce( filter( path(...$arrayField), 'tmp', eq(variable("tmp", ...$filterField), $filterValue) ), 0, add(variable('value'), variable("this", $sumField)) ) ]) ]);
instead of this:
$collection->aggregate([ ['$project' => [ 'field' => ['$reduce' => [ 'input' => ['$filter' => [ 'input' => '$' . join('.', $arrayField), 'as' => 'tmp', 'cond' => ['$eq' => ["\$\$tmp." . join('.', $filterField), $filterValue]] ]], 'initialValue' => 0, 'in' => [ '$add' => ['$$value', '$$this.' . $sumField] ] ]] ]] ]);