Skip to content

Instantly share code, notes, and snippets.

@Igor-Lopes
Created July 8, 2018 19:40
Show Gist options
  • Save Igor-Lopes/637812cc3f862a54200c7d2279e256b5 to your computer and use it in GitHub Desktop.
Save Igor-Lopes/637812cc3f862a54200c7d2279e256b5 to your computer and use it in GitHub Desktop.
Sequelize Transaction Example
let transaction
try {
transaction = await Sequelize.transaction()
let employee = await Employee.create({
name: req.body.name,
employeeId: req.body.employeeId,
birthday: req.body.birthdate
}, transaction)
//... other transactions ... then commit
await transaction.commit()
} catch (ex) {
await transaction.rollback()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment