DB\Jig\Mapper::update PHP Method

update() public method

Update current record
public update ( ) : array
return array
    function update()
    {
        $db = $this->db;
        $now = microtime(TRUE);
        $data =& $db->read($this->file);
        if (isset($this->trigger['beforeupdate']) && \Base::instance()->call($this->trigger['beforeupdate'], [$this, ['_id' => $this->id]]) === FALSE) {
            return $this->document;
        }
        $data[$this->id] = $this->document;
        $db->write($this->file, $data);
        $db->jot('(' . sprintf('%.1f', 1000.0 * (microtime(TRUE) - $now)) . 'ms) ' . $this->file . ' [update] ' . json_encode($this->document));
        if (isset($this->trigger['afterupdate'])) {
            \Base::instance()->call($this->trigger['afterupdate'], [$this, ['_id' => $this->id]]);
        }
        return $this->document;
    }