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


TypeScript helpers.getDocumentId函數代碼示例

本文整理匯總了TypeScript中shared/helpers.getDocumentId函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getDocumentId函數的具體用法?TypeScript getDocumentId怎麽用?TypeScript getDocumentId使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: getDocumentId

  schema.path('slug').validate(function(value, respond) {
    var query = this.constructor.count();

    if(this.id) {
      query.where('_id').ne(this.id);
    }

    // Make sure the slug is unique in this shop
    if(options && options.uniqueShop) {
      query.where('shop_id', getDocumentId(this.shop_id));
    }

    // Make sure it's unique for parent (used in categories)
    if(options && options.uniqueParent) {
      query.where('parent_id', getDocumentId(this.parent_id));
    }

    // Make sure it's unique for this user
    if(options && options.uniqueUser) {
      query.where('user_id', getDocumentId(this.user_id));
    }

    query.where('slug', this.slug);

    return query.exec().then(function(count) {
      if(count > 0) {
        respond(false);
      } else {
        respond(true);
      }
    }, function() {
      respond(false);
    });

  }, 'Slug must be unique');
開發者ID:kaka3004,項目名稱:cms,代碼行數:35,代碼來源:slug-plugin.ts

示例2: function

 cartSchema.method('replaceAttributes', function(attributes) {
   this.items = attributes.items;
   this.totals = attributes.totals;
   this.total_items = attributes.total_items;
   this.total_unique_items = attributes.total_unique_items;
   this.shop_id = getDocumentId(attributes.shop_id);
   this.user_id = getDocumentId(attributes.user_id);
 });
開發者ID:kaka3004,項目名稱:cms,代碼行數:8,代碼來源:cart-model.ts

示例3: function

 productSchema.method('updateAttributes', function(attributes) {
   
   if(attributes.title) {
     this.title = attributes.title;
   }
   
   if(attributes.slug) {
     this.slug = attributes.slug;
   }
   
   if(attributes.body_html) {
     this.body_html = attributes.body_html;
   }
   
   if(attributes.description) {
     this.description = attributes.description;
   }
   
   if(attributes.gender) {
     this.gender = attributes.gender;
   }
   
   if(attributes.images) {
     this.images = attributes.images;
   }
   
   if(attributes.tags) {
     this.tags = attributes.tags;
   }
   
   if(attributes.variants_options) {
     this.variants_options = this.variants_options.concat(attributes.variants_options);
   }
   
   if(attributes.variants) {
     this.variants = this.variants.concat(attributes.variants);
   }
   
   if(attributes.category_id) {
     this.category_id = getDocumentId(attributes.category_id);
   }
   
   if(attributes.publish_status) {
     this.publish_status = attributes.publish_status;
   }
   
   if(attributes.published_at) {
     this.published_at = attributes.published_at;
   }
 });
開發者ID:kaka3004,項目名稱:cms,代碼行數:50,代碼來源:product-model.ts

示例4: function

 shopSchema.method('setCreator', function(creator) {
   this.creator_id = getDocumentId(creator);
 });
開發者ID:kaka3004,項目名稱:cms,代碼行數:3,代碼來源:shop-model.ts

示例5: create

  public create(attributes: IProduct, shop: IShop, user: IUser) {
    attributes.shop_id = getDocumentId(shop);
    attributes.creator_id = getDocumentId(user);

    return ProductModel.create(attributes);
  }
開發者ID:kaka3004,項目名稱:cms,代碼行數:6,代碼來源:product-repository.ts


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