本文整理匯總了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 }
);