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 IPayTMBody { payTMNo?: string; payeeName?: string; } export interface IPayTM { _id?: string; payTM?: { virtualId?: string; status?: string; info?: IPayTMBody; }; } /** Sequelize Schema */ export interface PayTMDocument extends Document { _id: string; payTM?: { virtualId?: string; status?: string; info?: IPayTMBody; }; } export class PayTMModel extends MongoModel { TABLE_NAME = "profile_users"; constructor(dbName: string) { super(dbName); } getDataModel(doc: PayTMDocument): IPayTM { if (!doc) { throw new LogAndError("Invalid document object"); } try { return { _id: doc._id , payTM: doc.payTM } } catch (e) { throw e; } } async defineSchema() { try { if (!this.DATABASE_NAME || !this.TABLE_NAME) { throw new LogAndError('Invalid database name or table name'); } let schema = new Schema({ _id: SchemaTypes.String }, { collection: this.TABLE_NAME } ); await this.define(schema); } catch (e) { throw e; } } }