How to use the Transaction function from sequelize
Find comprehensive JavaScript sequelize.Transaction code examples handpicked from public code repositorys.
48 49 50 51 52 53 54 55 56 57
// we lock the database logger.info(`Gateway backup: Locking Database`); // It's possible to get "Cannot start a transaction within a transaction" errors // So we might want to retry this part a few times await retry(async (bail, attempt) => { await db.sequelize.transaction({ type: Sequelize.Transaction.TYPES.IMMEDIATE }, async () => { logger.info(`Backup attempt n°${attempt} : Cleaning backup folder`); // we delete old backups await fse.emptyDir(this.config.backupsFolder); // We backup database
264
0
79
+ 3 other calls in file
GitHub: mozilla/snakepit
214 215 216 217 218 219 220 221
let options try { if (simulation) { options = {} } else { let transaction = await sequelize.transaction({ type: Sequelize.Transaction.TYPES.EXCLUSIVE }) options = { transaction: transaction, lock: transaction.LOCK } }
16
47
13
38 39 40 41 42 43 44 45 46 47
const rewardUser = async (user) => { const bonusAmount = SIGNUP_BONUS; logger.info(`Rewarding user with ${bonusAmount} tokens`, user); const {userId} = user; return sequelize.transaction({isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.SERIALIZABLE}) .then(async (t) => { try { // if (user.referredby) { // const referralOptions = {remarks: `Referral bonus for ${user.email} registration`};
1
0
2
sequelize.col is the most popular function in sequelize (1002 examples)