當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。