thesebas / php-mongodb-helpers
MongoDB php helpers to build queries
Installs: 13
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/thesebas/php-mongodb-helpers
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-09-25 12:34:32 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] ] ]] ]] ]);