本文整理汇总了TypeScript中Sequelize.Sequelize.transaction方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Sequelize.transaction方法的具体用法?TypeScript Sequelize.transaction怎么用?TypeScript Sequelize.transaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sequelize.Sequelize
的用法示例。
在下文中一共展示了Sequelize.transaction方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: transact
async function transact() {
const t = await sequelize.transaction({
deferrable: Deferrable.SET_DEFERRED(['test']),
isolationLevel: Transaction.ISOLATION_LEVELS.READ_COMMITTED,
type: Transaction.TYPES.DEFERRED,
});
await t.commit();
await t.rollback();
}
示例2: trans
async function trans() {
const a: number = await sequelize.transaction(async transaction => {
transaction.afterCommit(() => console.log('transaction complete'));
User.create(
{
data: 123,
},
{
transaction,
}
);
return 1;
});
}
示例3: upsert_event
return new Promise<EventMessage>((resolve, reject) => {
conn.transaction((transaction: Transaction) => {
return upsert_event(data, ev_data, transaction).then((ev: EventMessage) => {
// get all active sources and figure out which ones need to be deleted and
// upsert the reset
return set_event_sources(ev, data, you, transaction).then(sources => {
// get all active tags and figure out which ones need to be deleted and
// upsert the reset
return set_event_tags(ev, data, you, transaction).then(tag_ids => {
// get all active company_events and figure out which ones need to be
// deleted and upsert the reset
return set_event_companies(ev, data, you, transaction).then(company_ids => {
return build_event_message(ev, sources, tag_ids, company_ids);
});
});
});
});
})
.then(resolve)
.catch(reject);
});
示例4: nestedTransact
async function nestedTransact() {
const tr = await sequelize.transaction({
transaction: await sequelize.transaction(),
});
await tr.commit();
}
示例5:
});
});
sequelize
.query('INSERT into test set test=1', {
type: QueryTypes.INSERT,
})
.then(([aiId, affected]) => {
console.log(aiId, affected);
});
sequelize.transaction<void>(async transaction => {
const rows = await sequelize
.query('SELECT * FROM `user`', {
retry: {
max: 123,
},
model: User,
transaction,
logging: true,
})
});
sequelize.query('SELECT * FROM `user` WHERE status = $1',
{ bind: ['active'], type: QueryTypes.SELECT }
);
sequelize.query('SELECT * FROM `user` WHERE status = $status',
{ bind: { status: 'active' }, type: QueryTypes.SELECT }
);