当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Sequelize.query方法代码示例

本文整理汇总了TypeScript中Sequelize.Sequelize.query方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Sequelize.query方法的具体用法?TypeScript Sequelize.query怎么用?TypeScript Sequelize.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sequelize.Sequelize的用法示例。


在下文中一共展示了Sequelize.query方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

sequelize.transaction<void>(async transaction => {
  const rows = await sequelize
    .query('SELECT * FROM `user`', {
      retry: {
        max: 123,
      },
      model: User,
      transaction,
      logging: true,
    })
});
开发者ID:overlookmotel,项目名称:sequelize,代码行数:11,代码来源:connection.ts

示例2: function

        (Task as any).prototype.touch = async function(this: TaskInstance) {
            debug(`${process.pid} '.touch()' called for task ${this.name} (${this.id})`);
            this.emit('touch');

            await this.sequelize.query(`UPDATE "Locks" SET "updatedAt" = NOW() WHERE "TaskId" = :task_id`, {
                replacements: {
                    task_id: this.id,
                },
                type: QueryTypes.UPDATE,
            });
        };
开发者ID:CodeZavod,项目名称:scheduler,代码行数:11,代码来源:Models.ts

示例3: performOps

  /**
   * Batches operations together and performs them parallelly (eventually in a transaction)
   * @param {Array<IDBOp<any>>} what
   * @param {sequelize.Transaction} transaction
   * @returns {Promise<[Model<string>[] , any]>}
   */
  public async performOps(what: Array<DBOp<any>>, transaction?: sequelize.Transaction) {
    const baseOptions: any = { raw: true };
    if (transaction) {
      baseOptions.transaction = transaction;
    }

    const opsToDoIterator = this.splitOps(what, 1010);
    let chunk = opsToDoIterator.next();
    while (!chunk.done) {
      chunk = await (async () => {
        const p = this.sequelize.query(chunk.value, baseOptions);
        const nextChunk = await wait(1).then(() => opsToDoIterator.next());
        return p.then(() => nextChunk);
      })();
    }
    await this.sequelize.query(chunk.value, baseOptions);
  }
开发者ID:RiseVision,项目名称:rise-node,代码行数:23,代码来源:db.ts

示例4: merge

    return new Promise<Object | Object[]>((resolve, reject) => {
        var replacements = merge(defaults, params),
            merged_sql = sql({ auth, query: replacements }),
            required_params = get_params(merged_sql);

        try {
            check_params(required_params, replacements);
            conn.query(merged_sql, { replacements })
                .then(one_row ? head : pass)
                .then(head)
                .then(processor)
                .then(resolve)
                .catch(reject);
        } catch (err) {
            reject(err);
        }
    });
开发者ID:consumr-project,项目名称:cp,代码行数:17,代码来源:query.ts

示例5: await

 chunk = await (async () => {
   const p = this.sequelize.query(chunk.value, baseOptions);
   const nextChunk = await wait(1).then(() => opsToDoIterator.next());
   return p.then(() => nextChunk);
 })();
开发者ID:RiseVision,项目名称:rise-node,代码行数:5,代码来源:db.ts

示例6: Sequelize

import { QueryTypes, Sequelize, SyncOptions } from 'sequelize';
import { User } from 'models/User';

export const sequelize = new Sequelize('uri');

sequelize.afterBulkSync((options: SyncOptions) => {
  console.log('synced');
});

sequelize
  .query('SELECT * FROM `test`', {
    type: QueryTypes.SELECT,
  })
  .then(rows => {
    rows.forEach(row => {
      console.log(row);
    });
  });

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: {
开发者ID:overlookmotel,项目名称:sequelize,代码行数:31,代码来源:connection.ts

示例7: Sequelize

import { QueryTypes, Sequelize, SyncOptions } from 'sequelize';

export const sequelize = new Sequelize('uri');

sequelize.afterBulkSync((options: SyncOptions) => {
    console.log('synced');
});

sequelize
    .query('SELECT * FROM `test`', {
        type: QueryTypes.SELECT,
    })
    .then(rows => {
        rows.forEach(row => {
            console.log(row);
        });
    });

sequelize
.query('INSERT into test set test=1', {
    type: QueryTypes.INSERT,
})
.then(([aiId, affected]) => {
    console.log(aiId, affected);
});
开发者ID:,项目名称:,代码行数:25,代码来源:

示例8: select

export function select(sql: string) {
	return sequelize.query(sql, { type: QueryTypes.SELECT })
}
开发者ID:yuedun,项目名称:nodejs-koa,代码行数:3,代码来源:db-connection.ts


注:本文中的Sequelize.Sequelize.query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。