Created
July 8, 2018 19:40
-
-
Save Igor-Lopes/637812cc3f862a54200c7d2279e256b5 to your computer and use it in GitHub Desktop.
Sequelize Transaction Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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