Batman.Transaction is mixed into the new record created by
Batman.Model::transaction. It redefines and adds a few functions so that the resulting "transaction" will behave like a model. For example:
product = new App.Product(name: "Orange Glo") productTransaction = product.transaction() productTransaction.set("name", "Sham-Wow") # Changing the transaction doesn't affect the base record: product.get('name') # "Orange Glo" # Until changes are applied: productTransaction.save() product.get('name') # "Sham-Wow"
Shows that this
Batman.Modelis actually a transaction.
Batman.Modelthat this transaction came from.
Applies changes from the transaction to the base
visitedis an array of models which have already had their changes applied (so that those models don't have their changes applied repeatedly).
applyChangesalso applies changes on associated records.
Returns the base
Meant to behave just like
Batman.Model::save. The callback will be called with
(error, record, env). Calling
saveon a transaction:
- Validates the transaction
- If validation was successful, applies changes
- If validation was successful, saves the record