Skip to content

Instantly share code, notes, and snippets.

@codemariner
Created January 25, 2019 17:21
Show Gist options
  • Save codemariner/751e3361d9e90c84d77809830160c6b6 to your computer and use it in GitHub Desktop.
Save codemariner/751e3361d9e90c84d77809830160c6b6 to your computer and use it in GitHub Desktop.

Revisions

  1. codemariner created this gist Jan 25, 2019.
    35 changes: 35 additions & 0 deletions foo.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    export type DbFields<T> = {
    [K in keyof T]-?: T[K] | null;
    }

    export interface OrderFields {
    currency?: string;
    customerId?: string;
    customerName?: string;
    creationDate?: Date;
    email?: string;
    lastModified?: Date;
    orderId?: string;
    orderNo?: string;
    orderStatusId?: number;
    orderTotal?: number;
    productTotal?: number;
    recordCreated?: Date;
    recordUpdated?: Date;
    region?: string;
    shippingTotal?: number;
    siteId?: string;
    taxTotal?: number;
    }

    export type NewOrderData = DbFields<OrderFields> & {
    orderStatusId: number;
    orderNo: string;
    }

    export type OrderData = DbFields<OrderFields> & {
    orderId: number;
    orderStatusId: number;
    recordCreated: Date;
    recordUpdated: Date;
    }