MongoDB createAggregationBuilder with Simultaneous operations

0
public function inventario(\App\Document\Tecnico $tecnico, $value)
{
    $builder = $this->createAggregationBuilder();
    $builder
        ->hydrate(\App\Document\Inventario::class)
        ->match()
            ->field('tecnico')
            ->references($tecnico)
            ->field('tipo')
            ->equals($value)
        ->group()
            ->field('_id')
            ->expression('$material')
            ->field('subtotal')
            ->sum('$cantidad')
        ;

    return $builder->execute();

}

$ value is the value that I want to condition for the case where q is 'cond1' add and when it is 'cond2' subtract for the subtotal.

With this I get the results of the past value (cond1 or cond2) but I can not do that simultaneous operation.

    
asked by Nicoo1991 07.06.2018 в 00:13
source

0 answers