protected function doFlush($dataset, array $conditions)
    {
        !$this->useTransaction ?: $this->db->getTransaction(true)->start();

        try {
            if ($this->delete($conditions) === false) {
                throw new \RuntimeException(sprintf('Delete row fail when updating relations table: %s', $this->table));
            }

            if ($this->create($dataset) === false) {
                throw new \RuntimeException(sprintf('Insert row fail when updating relations table: %s', $this->table));
            }
        } catch (\Throwable $e) {
            !$this->useTransaction ?: $this->db->getTransaction(true)->rollback();

            throw $e;
        }

        !$this->useTransaction ?: $this->db->getTransaction(true)->commit();

        return $dataset;
    }