Method: Dynamoid::TransactionWrite#destroy

Defined in:
lib/dynamoid/transaction_write.rb

#destroy(model) ⇒ Dynamoid::Document

Delete a model.

Runs callbacks.

Raises Dynamoid::Errors::MissingHashKey if a partition key has value nil and raises Dynamoid::Errors::MissingRangeKey if a sort key is required but has value nil.

There are the following differences between transactional and non-transactional #destroy:

  • transactional #destroy doesn’t support lock_version attribute so it will not be incremented and will not be checked to detect concurrent modification of a model and Dynamoid::Errors::StaleObjectError exception will not be raised

  • transactional #destroy doesn’t disassociate a model from associated ones if there are association declared in the model class

Parameters:

Returns:



655
656
657
658
# File 'lib/dynamoid/transaction_write.rb', line 655

def destroy(model)
  action = Dynamoid::TransactionWrite::Destroy.new(model, raise_error: false)
  register_action action
end