Skip to content

Instantly share code, notes, and snippets.

@mickhansen
Last active December 25, 2015 20:49
Show Gist options
  • Save mickhansen/7037710 to your computer and use it in GitHub Desktop.
Save mickhansen/7037710 to your computer and use it in GitHub Desktop.
sequelize.transaction(function (t) {
User.find({transaction: t, where: {id: 1}}).done(function (err, user) {
if (err) return t.rollback();
user.updateAttributes({transaction:t, where: {foo: 'bar'}}).done(function (err) {
if (err) return t.rollback();
t.commit();
});
});
t.done(function (err) {
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment