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