Created
June 2, 2018 03:22
-
-
Save greyscaled/b15fa67fdc1581fd8ed63a81ebc2608e to your computer and use it in GitHub Desktop.
This file contains 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 { | |
// Unmanaged Transaction | |
transaction = await sequelize.transaction() | |
// make sure to use the transaction in options | |
await Team.create({...},{transaction}) | |
// always call commit at the end | |
await transaction.commit() | |
} catch (err) { | |
// always rollback | |
await transaction.rollback() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment