Transaction Delete and Existance Now that Transaction acts as a kind of repo, there's two other methods I'm going to want for the future.
1 files changed, 14 insertions(+), 0 deletions(-) M lib/transaction.rb
M lib/transaction.rb => lib/transaction.rb +14 -0
@@ 23,6 23,20 @@ class Transaction end end def delete ids = [@transaction_id, "bonus_for_#{@transaction_id}"] DB.query_defer(<<~SQL, ids) DELETE FROM transactions WHERE transaction_id IN ($1, $2) SQL end def exists? DB.query_one(<<~SQL, @transaction_id).then { |r| r[:count] == 1 } SELECT COUNT(1) FROM transactions WHERE transaction_id = $1 SQL end def total amount + bonus end