當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Model.create方法代碼示例

本文整理匯總了TypeScript中Sequelize.Model.create方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Model.create方法的具體用法?TypeScript Model.create怎麽用?TypeScript Model.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sequelize.Model的用法示例。


在下文中一共展示了Model.create方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: defineSettings

  /**
   * Define settings for context (plugin or core/app).
   * @param context
   * @param schema
   */
  public async defineSettings (context: any, schema: SettingSchema) {
    context = this.getContextString(context);

    // Prepare all settings in database.
    for (let setting of schema.settings) {
      setting.value = null;
      await this.settingModel.create(setting);
    }
  }
開發者ID:tomvlk,項目名稱:ManiaJS,代碼行數:14,代碼來源:SettingManager.ts

示例2: create

 create(item: T, callback: (error: any, result: any) => void) {
     this.schema_model.create(item)
         .then((data) => {
             return callback(null, data);
         })
         .catch((error) => {
             return callback(error, null);
         });
 }
開發者ID:pmatam,項目名稱:nodejs,代碼行數:9,代碼來源:base_repository.ts

示例3: boot

  public async boot() {
    let Map: Model<any,any> = this.app.models['Map'];

    // Get all maps on server, sync with database.
    let mapList: any[] = await this.app.serverFacade.client.gbx.query('GetMapList', [-1, 0]);

    // Clear current list first.
    this.list = {};

    // TODO: Define interfaces for the maniaplanet return values.
    for (let data of mapList) {
      let exists = await Map.findOne({where: {uid: data.UId}});
      if (! exists) {
        let map = await Map.create({
          uid: data.UId,
          name: data.Name,
          author: data.Author,
          environment: data.Environnement
        });

        // Save created database model to local list.
        this.list[data.UId] = map;

      } else {
        // Name update?
        if (exists.name !== data.Name) {
          exists.set('name', data.Name);
          let map = await exists.save();
          this.list[data.UId] = map;
        } else {
          this.list[data.UId] = exists;
        }
      }
    }

    // The sync with db is done, now check the current map and set it in the this.current
    let currentMapInfo = await this.app.serverFacade.client.gbx.query('GetCurrentMapInfo', []);
    if (currentMapInfo) {
      this.current = this.list[currentMapInfo.UId];
    }
  }
開發者ID:tomvlk,項目名稱:ManiaJS,代碼行數:41,代碼來源:Maps.ts


注:本文中的Sequelize.Model.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。