DynamoDB Dynomite Deleting
Important: These docs are for the outdated Jets 5 versions and below. For the latest Jets docs: docs.rubyonjets.com
Destroy
Will run callbacks:
post = Post.find_by(title: 'post 1')
post.destroy
Delete
Will bypass callbacks:
post = Post.find_by(title: 'post 1')
post.delete
Batch Deleting
The delete_all
deletes without running callbacks and also uses batch_write_item to delete faster.
Post.delete_all
You can scope it with normal relation querying.
Post.where(title: "post 1").delete_all
Post.limit(2).delete_all
You can also use delete_by
to do the same thing:
Post.delete_by(title: "post 1")
Post.limit(2).delete_by(title: "post 1")
Batch Destroying
There are also the corresponding destroy_all
and destroy_by
methods, which will run callbacks.
Post.destroy_all
Post.destroy_by(title: "post 1")