mongodb - $slice implemented in the php driver? -
my question if 1 can use '$slice' update() , $push in mongodb.
i tried this: (with , without casting (object)
$db->collection->update( array('_id' => new mongoid($id)), (object)array( '$push' => array('thumbs' => array( '$each' => $items, '$slice' => -5 ))));
but thing happens mongo adding whole second array in update() collection. get
thumbs: [ { "$each" : ...
thanks in advance!
you running mongodb pre 2.4.
mongodb 2.4 introduced $slice, , previous $push operator did not support $each operator.
when mongodb encounters unrecognised operators (i.e. in mongodb 2.2) $push believe keys want use , treat other data.