You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 18, 2020. It is now read-only.
Hi @Lida, thank you for pointing that out. Basically, RethinkDB has built-in support for atomic updates. You don't have to rely on Ecto's optimistic lock to allow lock-free updates on a single record.
I will investigate why the update did not work as excepted.
Hi @almightycouch, the optimistic locking is being used to make sure concurrent updates doesn't conflict. For example allowing multiple user to increment a counter. I am currently using ReQL directly to make sure we don't clobber any updates.
table("counters") |> get(model.id) |> update((lambda fn(row) ->
if row["version"] == model.version do
Map.merge(params, %{version: model.version + 1})
else
error("Can't update")
end
end))
I was running the example in Ecto's doc for optimistic locking while using RethinkDB.Ecto as the adapter.
Repo.update!(stale_change)
didn't update the row, but it didn't throw aEcto.StaleModelError
either.What is going on here?
The text was updated successfully, but these errors were encountered: