EctoTablestore.Repo.update
update
, go back to EctoTablestore.Repo module for more information.
Specs
update(changeset :: Ecto.Changeset.t(), options()) :: {:ok, schema()} | {:error, term()}
Updates a changeset using its primary key.
Options
:condition
, this option is required, whether to add conditional judgment before data update.- As
condition(:expect_exist)
means the primary key(s) can match a row to update, if the row is existed, the update result will be success, if the row is not existed, the update result will be fail. We also can add some compare expressions for the attribute columns, e.g:condition(:expect_exist, "attr1" == value1 and "attr2" > 1) condition(:expect_exist, "attr1" != value1) condition(:expect_exist, "attr1" > 100 or "attr2" < 1000)
- As
condition(:ignore)
means DO NOT do any condition validation before update, whether the row exists or not, both of the update results will be success. - As
condition(:expect_not_exist)
means expect the primary key(s) are NOT existed before update, if the row is existed, the update will be fail, if the row is not existed, the update result will be success.
- As
:transaction_id
, update under local transaction in a partition key.:stale_error_field
- The field where stale errors will be added in the returning changeset. This option can be used to avoid raisingEcto.StaleEntryError
.:stale_error_message
- The message to add to the configured:stale_error_field
when stale errors happen, defaults to "is stale".:returning
, this option is required when the input changeset with:increment
operation, all fields of the atomic increment operation are required to explicitly set into this option in any order, if missed any atomic increment operation related field, there will raise anEcto.ConstraintError
to prompt and terminate this update. If there is no:increment
operation, the:returning
option is no need to set. If setreturning: true
, but not really all fields are changed, the unchanged fields will be replaced asnil
in the returned schema data.