All files / examples/order-more/entities product-variant.ts

100% Statements 24/24
100% Branches 0/0
100% Functions 2/2
100% Lines 24/24

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87              1x   1x                                                                                 69x 69x 69x 69x 69x 69x 69x 69x 69x 69x 69x 69x 69x 69x 69x 69x 69x 69x 69x 69x             6x       1x            
import { Product } from './product';
import { ActualProductVariant } from './actual-product-variant';
import { Color } from './color';
import { Gender } from './gender';
import { Size } from './size';
import { IEntity, ICollection, IColumns } from '../../../src/index';
 
export const tableName: string = 'product_variant';
 
export const columns: IColumns = [
  'id',
  { column: 'product_id', references: Product },
  { column: 'actual_product_variant_id', references: ActualProductVariant },
  { column: 'color_id', references: Color },
  { column: 'gender_id', references: Gender },
  { column: 'size_id', references: Size },
  'shopify_id',
  'image_url',
  'barcode',
  'price',
  'compare_at_price',
  'created_date',
  'updated_date',
  'grams',
  'requires_shipping'
];
 
export class ProductVariant implements IEntity {
  id: number;
  productId: number;
  product?: Product;
  actualProductVariantId: number;
  actualProductVariant?: ActualProductVariant;
  colorId: number;
  color?: Color;
  genderId: number;
  gender?: Gender;
  sizeId: number;
  size?: Size;
  shopifyId: number;
  imageUrl: string;
  barcode: string;
  price: number;
  compareAtPrice: number;
  createdDate: Date;
  updatedDate: Date;
  grams: number;
  requiresShipping: boolean;
 
  constructor(props: any) {
    this.id = props.id;
    this.productId = props.productId;
    this.product = props.product;
    this.actualProductVariantId = props.actualProductVariantId;
    this.actualProductVariant = props.actualProductVariant;
    this.colorId = props.colorId;
    this.color = props.color;
    this.genderId = props.genderId;
    this.gender = props.gender;
    this.sizeId = props.sizeId;
    this.size = props.size;
    this.shopifyId = props.shopifyId;
    this.imageUrl = props.imageUrl;
    this.barcode = props.barcode;
    this.price = props.price;
    this.compareAtPrice = props.compareAtPrice;
    this.createdDate = props.createDate;
    this.updatedDate = props.updateDate;
    this.grams = props.grams;
    this.requiresShipping = props.requiresShipping;
  }
}
 
export class ProductVariants implements ICollection<ProductVariant> {
  models: Array<ProductVariant>;
  constructor({ models }: any) {
    this.models = models;
  }
}
 
export const productVariantConfiguration = {
  tableName,
  columns,
  entityClass: ProductVariant,
  collectionClass: ProductVariants,
}