This sample is from the online docos
db = ::Rho::RHO.get_src_db('Model')
db.start_transaction
begin
items.each do |item|
# create hash of attribute/value pairs
data = {
:field1 => item['value1'],
:field2 => item['value2']
}
# Creates a new Model object and saves it
new_item = Model.create(data)
end
db.commit
rescue
db.rollback
end
My question is, does that transaction span models such that I could create multiple new records of several dependent model types and, in the face of an eror, do a single rollback to revert them at once?
1 Replies
Hi Tom,
Yes it can revert all pending actions before a commit via single rollback command.
For latest version Please refer the link http://docs.rhomobile.com/en/5.0.0/api/Database#mrollbackTransaction
Visnupriya R
Kutir Mobility