public function save($data)
    {
        if (!isset($data[$this->primaryKey])) {
            $data[$this->primaryKey] = 0;
        }

        try {
            if (0 === $data[$this->primaryKey]) {
                unset($data[$this->primaryKey]);

                $id = $this->insert($data);
            } else {
                if ($this->find($data[$this->primaryKey], true)) {
                    $this->update($data);
                } else {
                    $this->insert($data);
                }

                $id = $data[$this->primaryKey];
            }
        } catch(\Exception $e) {
            return [
                'code' => $e->getCode(),
                'message' => $e->getMessage()
            ];
        }

        return $id;
    }