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


TypeScript Sequelize.Sequelize类代码示例

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


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

示例1: function

export default function (sequelize: Sequelize, DataTypes: DataTypes) {
  let Map = sequelize.define('Map', {
    uid: {
      type: DataTypes.STRING,
      allowNull: false
    },
    name: {
      type: DataTypes.STRING,
      allowNull: false
    },
    author: {
      type: DataTypes.STRING,
      allowNull: false
    },
    environment: {
      type: DataTypes.STRING,
      allowNull: false
    }
  }, {
    tableName: 'core__map',
    charset: 'utf8'
  });

  return Map;
}
开发者ID:tomvlk,项目名称:ManiaJS,代码行数:25,代码来源:Map.ts

示例2: function

export default function (sequelize: Sequelize, DataTypes: DataTypes) {
  let Setting = sequelize.define('Setting', {
    context: {
      type: DataTypes.STRING,
      allowNull: false
    },
    key: {
      type: DataTypes.STRING,
      allowNull: false
    },
    name: {
      type: DataTypes.STRING,
      allowNull: false
    },
    type: {
      type: DataTypes.STRING,
      allowNull: false
    },
    enumeration: {
      type: DataTypes.TEXT,
      allowNull: true
    },
    description: {
      type: DataTypes.TEXT,
      allowNull: true
    },
    value: {
      type: DataTypes.TEXT,
      allowNull: true
    },
    category: {
      type: DataTypes.STRING,
      allowNull: true
    },
    visible: {
      type: DataTypes.BOOLEAN,
      defaultValue: true
    }
  }, {
    tableName: 'core__setting',
    charset: 'utf8',
    indexes: [
      {
        unique: true,
        fields: ['context', 'key']
      }
    ],
    hooks: {
      beforeValidate (setting: any, options) {
        if (setting.value && typeof setting.value !== 'string')
          setting.value = JSON.stringify({value: setting.value});
        if (setting.enumeration && Array.isArray(setting.enumeration))
          setting.enumeration = JSON.stringify(setting.enumeration);
      }
    }
  });

  return Setting;
}
开发者ID:tomvlk,项目名称:ManiaJS,代码行数:59,代码来源:Setting.ts

示例3: Promise

 return new Promise((resolve, reject) => {
     this._db.close().then(() => {
         resolve();
     }).catch((ex: Error) => {
         reject(ex);
     });
 });
开发者ID:weagle08,项目名称:node-start,代码行数:7,代码来源:Database.ts

示例4:

      list.forEach((file) => {
        // Import sequelize model.
        let model:any = this.sequelize.import(file);

        // Save to model storage of app.
        this.app.models[model.name] = model;
      });
开发者ID:tomvlk,项目名称:ManiaJS,代码行数:7,代码来源:Client.ts

示例5: handleDelete

 public handleDelete(deleteOp: DBRemoveOp<any>) {
   return this.sequelize.getQueryInterface().QueryGenerator.deleteQuery(
     deleteOp.model.getTableName(),
     deleteOp.options.where,
     { ...deleteOp.options, limit: null },
     deleteOp.model
   );
 }
开发者ID:RiseVision,项目名称:rise-node,代码行数:8,代码来源:db.ts

示例6: handleUpdate

 public handleUpdate(updateOp: DBUpdateOp<any>) {
   return this.sequelize.getQueryInterface().QueryGenerator.updateQuery(
     updateOp.model.getTableName(),
     updateOp.values,
     updateOp.options.where,
     updateOp.options
     );
 }
开发者ID:RiseVision,项目名称:rise-node,代码行数:8,代码来源:db.ts

示例7: handleInsert

 public handleInsert(insertOp: DBCreateOp<any>) {
   return this.sequelize.getQueryInterface().QueryGenerator.insertQuery(
     insertOp.model.getTableName(),
     insertOp.values,
     insertOp.model.rawAttributes,
     {}
   );
 }
开发者ID:RiseVision,项目名称:rise-node,代码行数:8,代码来源:db.ts

示例8: 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

示例9:

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


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