import { MongoModel } from '@birbal/mongo-utilities/dist/mongo-model'; import { LogAndError } from '@birbal/common-utilities/dist/error'; import { Document, Schema, SchemaTypes } from 'mongoose'; export interface IVirtualStateHistory { _id?: string , virtualId?: string , status?: string } /** Sequelize Schema */ export interface VirtualStateHistoryDocument extends Document { _id: string , virtualId?: string , status?: string } export class VirtualStateHistoryModel extends MongoModel { TABLE_NAME = "profile_virtual_history"; constructor(dbName: string) { super(dbName); } getDataModel(doc: VirtualStateHistoryDocument): IVirtualStateHistory { if (!doc) { throw new LogAndError("Invalid doc object"); } try { return { _id: doc._id , virtualId: doc.virtualId , status: doc.status } } catch (e) { throw e; } } async defineSchema() { try { if (!this.DATABASE_NAME || !this.TABLE_NAME) { throw new LogAndError('Invalid db name/ tbl name'); } let schema = new Schema({ _id: SchemaTypes.String , userType: SchemaTypes.String , status: SchemaTypes.String }, { collection: this.TABLE_NAME }); await this.define(schema); } catch (e) { throw e; } } }