本文整理汇总了TypeScript中Sequelize.Sequelize.import方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Sequelize.import方法的具体用法?TypeScript Sequelize.import怎么用?TypeScript Sequelize.import使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sequelize.Sequelize
的用法示例。
在下文中一共展示了Sequelize.import方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
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;
});
示例2: loadModels
/**
* Load all models from plugins.
*
* @param sequelize {Sequelize}
*
* @returns {Promise}
*/
public async loadModels(sequelize: Sequelize) {
if (this.order.length === 0) {
this.determinateOrder();
}
for (let id of this.order) {
if (this.plugins[id].directory) {
var modelDirectory = path.normalize(this.plugins[id].directory + '/models/');
var exists = await fs.exists(modelDirectory);
if (! exists) {
modelDirectory = path.normalize(this.plugins[id].directory + '/Models/');
exists = await fs.exists(modelDirectory);
if (! exists) continue;
}
try {
let list = glob.sync(modelDirectory + '*.js');
if (list.length > 0) {
for (let file of list) {
// Import sequelize model.
let model: any = sequelize.import(file);
// Set in the plugin.
if (! this.plugins[id].models) {
this.plugins[id].models = {};
}
this.plugins[id].models[model.name] = model;
// Set in the global models.
if (! this.app.models.hasOwnProperty(id)) {
this.app.models[id] = {};
}
this.app.models[id][model.name] = model;
}
}
} catch (err) {
this.app.log.warn('Warning, can\'t load models for plugin ' + id, err.stack);
}
}
}
}
示例3:
}).forEach((file: string) => {
let model = this._sequelize.import(path.join(__dirname, file));
this._models[(model as any).name] = model;
});