本文整理汇总了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;
}
示例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;
}
示例3: Promise
return new Promise((resolve, reject) => {
this._db.close().then(() => {
resolve();
}).catch((ex: Error) => {
reject(ex);
});
});
示例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;
});
示例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
);
}
示例6: handleUpdate
public handleUpdate(updateOp: DBUpdateOp<any>) {
return this.sequelize.getQueryInterface().QueryGenerator.updateQuery(
updateOp.model.getTableName(),
updateOp.values,
updateOp.options.where,
updateOp.options
);
}
示例7: handleInsert
public handleInsert(insertOp: DBCreateOp<any>) {
return this.sequelize.getQueryInterface().QueryGenerator.insertQuery(
insertOp.model.getTableName(),
insertOp.values,
insertOp.model.rawAttributes,
{}
);
}
示例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();
}
示例9:
sequelize.transaction<void>(async transaction => {
const rows = await sequelize
.query('SELECT * FROM `user`', {
retry: {
max: 123,
},
model: User,
transaction,
logging: true,
})
});