jrf0110 / dirac

A Node Postgres DB layer built with MoSQL
http://dirac.j0.hn
6 stars 2 forks source link

Transactions #26

Open jrf0110 opened 10 years ago

jrf0110 commented 10 years ago
dirac.tx( function( tx ){
  tx.dals.users.create({
    name: 'Tom'
  , profession: 'Beasting and Feasting'
  });
  tx.savepoint('user_created');

  tx.dals.user_hobbies.insert([
    { name: 'Skiiing', category: 7 }
  , { name: 'Polo', category: 22 }
  ]);
  tx.savepoint('hobbies_created');

  /* ... */
  tx.rollback('user_created');
  tx.abort();
  tx.commit();
}, function( error ){
  /* ... */
});