当前位置: 首页>>代码示例>>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;未经允许,请勿转载。