Description
This is a duplicate of an open issue on the original repository:
Also, I couldn't find any documentation where it explains the update
usage on this gem. Even if we do need to pass a block, what is it for? It should be added to the documentation and/or readme of this repository.
For what I can see in the code, from the yield block you obtain an ItemUpdater which is part of the adapter plugin for aws-sdk-v2, at the very least the readme should relay the documentation back to the aws gem if needed with how to use it.
TL;DR
The following code crashes and there's no documentation about how to handle it or use the update method.
class Foo
include Dynamoid::Document
table name: :data_messages
field :bar
end
Foo.first.update(bar: "this should be updated")
-> Raises LocalJumpError: no block given (yield) and the record is not updated.
Foo.first.update(bar: "this should be updated") { |iu| puts "I'm a weird block" }
-> No error but the record is not updated at all
So by digging into the codebase I found out the following is the actual way to update things (which is kind of unnatural), which makes the method a pain to use and figure out.
Foo.first.update { |iu| iu.set bar: "this should be updated" }
-> No error and the record is finally updated
Also please note that this is executing the update
method on the model instance and not the class.