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

94.44% Statements 17/18
100% Branches 0/0
50% Functions 1/2
94.44% Lines 17/18

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      1x   1x                                                                 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x                     1x            
import { Product } from './product';
import { IEntity, ICollection, IColumns } from '../../../src/index';
 
export const tableName: string = 'product_variant';
 
export const columns: IColumns = [
  'id',
  { column: 'product_id', references: Product },
  'actual_product_variant_id',
  'color_id',
  'gender_id',
  'size_id',
  '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;
  colorId: number;
  genderId: number;
  sizeId: number;
  barcode: number;
  price: number;
  compareAtPrice: number;
  createdDate: number;
  updatedDate: number;
  grams: number;
  requiresShipping: number;
 
  constructor(props: any) {
    this.id = props.id;
    this.productId = props.productId;
    this.product = props.product;
    this.actualProductVariantId = props.actualProductVariantId;
    this.colorId = props.colorId;
    this.genderId = props.genderId;
    this.sizeId = props.sizeId;
    this.barcode = props.barcode;
    this.price = props.price;
    this.compareAtPrice = props.compareAtPrice;
    this.createdDate = props.createdDate;
    this.updatedDate = props.updatedDate;
    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,
}