public function findAndUpdate(Operator $operator, $upsert = false, $returnUpdated = true)
    {
        $mongoDocument = $this->collection
            ->getMongoCollection()
            ->findAndModify(
                $this->expression->toArray(),
                $operator ? $operator->toArray() : null,
                $this->projection,
                array(
                    'new' => $returnUpdated,
                    'sort' => $this->sort,
                    'upsert' => $upsert,
                )
            );

        if (empty($mongoDocument)) {
            return null;
        }

        return $this->collection->hydrate($mongoDocument, $this->isDocumentPoolUsed());
    }
public function findAndUpdate(Operator $operator, $upsert = false, $returnUpdated = true)
    {
        $mongoDocument = $this->collection
            ->getMongoCollection()
            ->findAndModify(
                $this->expression->toArray(),
                $operator ? $operator->toArray() : null,
                $this->projection,
                array(
                    'new' => $returnUpdated,
                    'sort' => $this->sort,
                    'upsert' => $upsert,
                )
            );

        if (empty($mongoDocument)) {
            return null;
        }

        return $this->collection->hydrate($mongoDocument, $this->isDocumentPoolUsed());
    }
public function findAndUpdate ( Operator $ operator , $ upsert = false , $ returnUpdated = true ) { $ mongoDocument = $ this -> collection -> getMongoCollection ( ) -> findAndModify ( $ this -> expression -> toArray ( ) , $ operator ? $ operator -> toArray ( ) : null , $ this -> projection , array ( 'new' => $ returnUpdated , 'sort' => $ this -> sort , 'upsert' => $ upsert , ) ) ; if ( empty ( $ mongoDocument ) ) { return null ; } return $ this -> collection -> hydrate ( $ mongoDocument , $ this -> isDocumentPoolUsed ( ) ) ; }
Find first document and update it

@param Operator $operator operations with document to update
@param bool $upsert if document not found - create
@param bool $returnUpdated if true - return updated document

@return null|Document
Find first document and update it