Back
invokeWithTransaction()
Runs the specified method within a single database transaction.
// This is the method to be run inside a transaction. public boolean function transferFunds(required any personFrom, required any personTo, required numeric amount) { if (arguments.personFrom.withdraw(arguments.amount) && arguments.personTo.deposit(arguments.amount)) { return true; } else { return false; } } local.david = model("Person").findOneByName("David"); local.mary = model("Person").findOneByName("Mary"); invokeWithTransaction(method="transferFunds", personFrom=local.david, personTo=local.mary, amount=100);
Copied!