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


TypeScript Sequelize.import方法代码示例

本文整理汇总了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;
      });
开发者ID:tomvlk,项目名称:ManiaJS,代码行数:7,代码来源:Client.ts

示例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);
        }
      }
    }
  }
开发者ID:tomvlk,项目名称:ManiaJS,代码行数:49,代码来源:PluginManager.ts

示例3:

 }).forEach((file: string) => {
   let model = this._sequelize.import(path.join(__dirname, file));
   this._models[(model as any).name] = model;
 });
开发者ID:natarajanmca11,项目名称:sequelize-typescript-examples,代码行数:4,代码来源:index.ts


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