All files / lib/models QuotePharmacy.ts

100% Statements 9/9
100% Branches 0/0
100% Functions 1/1
100% Lines 9/9
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  1x 1x 1x 1x 1x 1x     2x 2x                                               1x                                  
import * as dynogels from 'drandx-dynogels';
import * as joi from 'joi';
import { BaseModel } from './BaseModel';
import { QUOTE_STATUS_ENUM } from './Enums';
import { Product } from './Product';
import { User } from './User';
import { awsConfig, globalConst } from '../config/db/appVariables';
import { Pharmacy } from './Pharmacy';
 
dynogels.AWS.config.update(awsConfig);
 
export class QuotePharmacy extends BaseModel {
    public quoteId: string;
    public pharmacyId: string;
    public products: Product[];
    public status: QUOTE_STATUS_ENUM;
    public total: number;
    public pharmacyPosition: {
        latitude: number,
        longitude: number,
    };
    public customer: User;
    public pharmacy: Pharmacy;
 
    constructor() {
        super();
    }
 
    public model: dynogels.Model = dynogels.define(`${globalConst.stage}_quote_pharmacy`, {
        hashKey: 'quoteId',
        rangeKey: 'pharmacyId',
        timestamps: false,
        schema: {
            quoteId: joi.string(),
            pharmacyId: joi.string(),
            createdAt: joi.number(),
            updatedAt: joi.number(),
            status: joi.string(),
            products: joi.array(),
            customer: joi.object(),
            pharmacy: joi.object(),
            total: joi.number(),      
            pharmacyPosition: joi.object(),
        },
        tableName: `${globalConst.stage}_quote_pharmacy`,
        indexes: [
            { hashKey: 'pharmacyId', rangeKey: 'createdAt', name: 'pharmacyId-createdAt-index', type: 'global' },
            { hashKey: 'status', rangeKey: 'updatedAt', name: 'statusIndex', type: 'global' },
            ],
    });
}