public function set(string $id, array $cfg = null): int
  {
    return $this->db->update($this->class_cfg['table'], [
      $this->fields['cfg'] => $cfg ? json_encode($this->get_cfg(false, $cfg)) : null
    ], [
      $this->fields['id'] => $id
    ]);
  }