From 851be1311e79cb79be8346c65e444be9121a1879 Mon Sep 17 00:00:00 2001 From: Andrew Konchin Date: Mon, 28 Oct 2024 17:46:47 +0200 Subject: [PATCH] Remove removed use cases from README_transact.md --- README_transact.md | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/README_transact.md b/README_transact.md index 4bbf8b67..2ebfac54 100644 --- a/README_transact.md +++ b/README_transact.md @@ -50,28 +50,15 @@ end ``` ### Update items -An item can be updated by providing the hash key, range key if applicable, and the fields to update. -Updating fields can also be done within a block using the `set()` method. -To increment a numeric value or to add values to a set use `add()` within the block. -Similarly a field can be removed or values can be removed from a set by using `delete()` in the block. +An item can be updated by providing a model or hash key and range key if applicable, and the fields to update. ```ruby Dynamoid::TransactionWrite.execute do |txn| - # sets the name and title for user 1 - # The user is found by id - txn.update!(User, id: 1, name: 'bob', title: 'mister') - - # sets the name, increments a count and deletes a field - txn.update!(user) do |u| # a User instance is provided - u.set(name: 'bob') - u.add(article_count: 1) - u.delete(:title) - end + # change name and title for a user + txn.update_attributes!(user, name: 'bob', title: 'mister') - # adds to a set of integers and deletes from a set of strings - txn.update!(User, id: 3) do |u| - u.add(friend_ids: [1, 2]) - u.delete(child_names: ['bebe']) - end + # sets the name and title for a user + # The user is found by id (that equals 1) + txn.update_fields!(User, 1, name: 'bob', title: 'mister') end ```