當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Sequelize.transaction方法代碼示例

本文整理匯總了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();
}
開發者ID:overlookmotel,項目名稱:sequelize,代碼行數:9,代碼來源:transaction.ts

示例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;
    });
}
開發者ID:overlookmotel,項目名稱:sequelize,代碼行數:14,代碼來源:transaction.ts

示例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);
 });
開發者ID:consumr-project,項目名稱:cp,代碼行數:21,代碼來源:event.ts

示例4: nestedTransact

async function nestedTransact() {
  const tr = await sequelize.transaction({
    transaction: await sequelize.transaction(),
  });
  await tr.commit();
}
開發者ID:overlookmotel,項目名稱:sequelize,代碼行數:6,代碼來源:transaction.ts

示例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 }
);
開發者ID:overlookmotel,項目名稱:sequelize,代碼行數:30,代碼來源:connection.ts


注:本文中的Sequelize.Sequelize.transaction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。