How do i use $inc using the object document mapper.
db.products.update( { sku: "abc123" }, { $inc: { quantity: -2, "metrics.orders": 1 } } )
Have you tried with something like
db.products.update( [ sku => "abc123" ], [ "$inc" => [ quantity => -2, "metrics.orders" => 1 ] ] )
or using array() instead of [] if using older PHP?
hmm, i am using the object document mapper. when i use ::update it says, function cannot be found
In the end i stick to the below. Any difference from using $inc? performance wise?
public function _incrementPageviews($id){ $page = Page::findById( $id ); $page->pageViews += 1; $page->save(); }