$slice
The `$slice` modifier limits the number of array elements during a $push operation.
Syntax
{
$push: {
field: {
$each: [ <value1>, <value2>, ... ],
$slice: <num>
}
}
}
Parameters
field
stringrequiredThe field to update.
<num>
numberrequiredAn integer that specifies the number of array elements to keep. If positive, keeps the first n elements. If negative, keeps the last n elements.