function update()
{
$pkey = ['_id' => $this->document['_id']];
if (isset($this->trigger['beforeupdate']) && \Base::instance()->call($this->trigger['beforeupdate'], [$this, $pkey]) === FALSE) {
return $this->document;
}
$this->collection->update($pkey, $this->document, ['upsert' => TRUE]);
if (isset($this->trigger['afterupdate'])) {
\Base::instance()->call($this->trigger['afterupdate'], [$this, $pkey]);
}
return $this->document;
}