当前位置: 首页>>代码示例>>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;未经允许,请勿转载。