protected function doUpdate($dataset, array $condFields, $updateNulls = false)
    {
        !$this->useTransaction ?: $this->db->getTransaction(true)->start();

        try {
            foreach ($dataset as $k => $data) {
                if (!$data instanceof $this->dataClass) {
                    $data = $this->bindData($data);
                }

                // If data is entity object, try cast values first.
                if ($data instanceof Entity) {
                    $data = $this->castForStore($data);
                }

                $entity = new Entity($this->getFields($this->table), $data);

                if ($updateNulls) {
                    $entity = $this->validValue($entity);
                }

                $this->db->getWriter()->updateOne($this->table, $entity, $condFields, $updateNulls);

                $dataset[$k] = $data;
            }
        } catch (\Throwable $e) {
            !$this->useTransaction ?: $this->db->getTransaction(true)->rollback();

            throw $e;
        }

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

        return $dataset;
    }