import { MongoFactory } from '@birbal/mongo-utilities/dist/mongo-factory'; import { MongoModel } from '@birbal/mongo-utilities/dist/mongo-model'; import { SearchUtility } from '@birbal/mongo-utilities/dist/mongo-search'; import { LogAndError } from '@birbal/common-utilities/dist/error'; import { Document, Schema, SchemaTypes, SchemaOptions } from 'mongoose'; export interface IAvatarInfoBody { avatarUrl?: string; } export interface IAvatarInfo { _id?: string; avatar?: { virtualId?: string; status?: string; info?: IAvatarInfoBody; }; } /** Sequelize Schema */ export interface IAvatarInfoDocument extends Document { _id: string; avatar?: { virtualId?: string; status?: string; info?: IAvatarInfoBody; }; } export class AvatarInfoModel extends MongoModel { TABLE_NAME = "profile_users"; constructor(dbName: string) { super(dbName); } getDataModel(doc: IAvatarInfoDocument): IAvatarInfo { if (!doc) { throw new LogAndError("Invalid documnet object"); } try { return { _id: doc._id , avatar: doc.avatar } } catch (e) { throw e; } } async defineSchema() { try { if (!this.DATABASE_NAME || !this.TABLE_NAME) { throw new LogAndError('Invalid db name or table name'); } let schema = new Schema({ _id: SchemaTypes.String }, { collection: this.TABLE_NAME } ); await this.define(schema); } catch (e) { throw e; } } }