本文整理匯總了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');
示例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);
});
示例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;
}
});
示例4: function
shopSchema.method('setCreator', function(creator) {
this.creator_id = getDocumentId(creator);
});
示例5: create
public create(attributes: IProduct, shop: IShop, user: IUser) {
attributes.shop_id = getDocumentId(shop);
attributes.creator_id = getDocumentId(user);
return ProductModel.create(attributes);
}