public function whereElemMatch($field, $expression)
    {
        if (is_callable($expression)) {
            $expression = call_user_func($expression, $this->expression());
        }

        if ($expression instanceof Expression) {
            $expression = $expression->toArray();
        } elseif (!is_array($expression)) {
            throw new Exception('Wrong expression passed');
        }

        return $this->where($field, array('$elemMatch' => $expression));
    }
public function whereElemMatch($field, $expression)
    {
        if (is_callable($expression)) {
            $expression = call_user_func($expression, $this->expression());
        }

        if ($expression instanceof Expression) {
            $expression = $expression->toArray();
        } elseif (!is_array($expression)) {
            throw new Exception('Wrong expression passed');
        }

        return $this->where($field, array('$elemMatch' => $expression));
    }
public function whereElemMatch ( $ field , $ expression ) { if ( is_callable ( $ expression ) ) { $ expression = call_user_func ( $ expression , $ this -> expression ( ) ) ; } if ( $ expression instanceof Expression ) { $ expression = $ expression -> toArray ( ) ; } elseif ( ! is_array ( $ expression ) ) { throw new Exception ( 'Wrong expression passed' ) ; } return $ this -> where ( $ field , array ( '$elemMatch' => $ expression ) ) ; }
Matches documents in a collection that contain an array field with at
least one element that matches all the specified query criteria.

@param string $field point-delimited field name
@param \Sokil\Mongo\Expression|callable|array $expression

@return Expression

@throws Exception
Matches documents in a collection that contain an array field with at least one element that matches all the specified query criteria .