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 IPanBody { panNo?: string; details?: { [key: string]: any }; expiry?: Date; } export interface IPan { _id?: string; pan?: { virtualId?: string; status?: string; info?: IPanBody; }; } /** Sequelize Schema */ export interface PanDocument extends Document { _id: string; pan?: { virtualId?: string; status?: string; info?: IPanBody; }; } export class PanModel extends MongoModel { TABLE_NAME = "profile_users"; constructor(dbName: string) { super(dbName); } getDataModel(doc: PanDocument): IPan { if (!doc) { throw new LogAndError("Invalid document object"); } try { return { _id: doc._id , pan: doc.pan } } 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; } } }