Sokil\Mongo\Operator::pushEachSlice PHP Method

pushEachSlice() public method

The $slice modifier limits the number of array elements during a $push operation. To project, or return, a specified number of array elements from a read operation, see the $slice projection operator instead.
public pushEachSlice ( string $field, integer $slice ) : Operator
$field string
$slice integer
return Operator
    public function pushEachSlice($field, $slice)
    {
        $slice = (int) $slice;
        if (!isset($this->operators['$push'][$field]['$each'])) {
            throw new Exception('Field ' . $field . ' must be pushed wit $each modifier');
        }
        $this->operators['$push'][$field]['$slice'] = $slice;
        return $this;
    }