function erase($filter = NULL)
{
if ($filter) {
return $this->collection->remove($filter);
}
$pkey = ['_id' => $this->document['_id']];
if (isset($this->trigger['beforeerase']) && \Base::instance()->call($this->trigger['beforeerase'], [$this, $pkey]) === FALSE) {
return FALSE;
}
$result = $this->collection->remove(['_id' => $this->document['_id']]);
parent::erase();
if (isset($this->trigger['aftererase'])) {
\Base::instance()->call($this->trigger['aftererase'], [$this, $pkey]);
}
return $result;
}