Mongolid\DataMapper\DataMapper::update PHP Method

update() public method

Notice: Updates with Unacknowledged WriteConcern will not fire updated event.
public update ( mixed $entity, array $options = [] ) : boolean
$entity mixed The entity used in the operation.
$options array Possible options to send to mongo driver.
return boolean Success (but always false if write concern is Unacknowledged)
    public function update($entity, array $options = []) : bool
    {
        if ($this->fireEvent('updating', $entity, true) === false) {
            return false;
        }
        if (!$entity->_id) {
            if ($result = $this->insert($entity, $options, false)) {
                $this->afterSuccess($entity);
                $this->fireEvent('updated', $entity);
            }
            return $result;
        }
        $data = $this->parseToDocument($entity);
        $queryResult = $this->getCollection()->updateOne(['_id' => $data['_id']], ['$set' => $data], $this->mergeOptions($options));
        $result = $queryResult->isAcknowledged() && $queryResult->getModifiedCount();
        if ($result) {
            $this->afterSuccess($entity);
            $this->fireEvent('updated', $entity);
        }
        return $result;
    }