Method: Dynamoid::Persistence::ClassMethods#update
- Defined in:
- lib/dynamoid/persistence.rb
#update(hash_key, range_key_value = nil, attrs) ⇒ Dynamoid::Document
Update document with provided attributes.
Instantiates document and saves changes. Runs validations and callbacks. Don’t save changes if validation fails.
User.update('1', age: 26)
If range key is declared for a model it should be passed as well:
User.update('1', 'Tylor', age: 26)
256 257 258 259 260 |
# File 'lib/dynamoid/persistence.rb', line 256 def update(hash_key, range_key_value = nil, attrs) model = find(hash_key, range_key: range_key_value, consistent_read: true) model.update_attributes(attrs) model end |