forked from Chatbot/v3-api
first commit v3 initialiazed a temporary repository for darmanet client
This commit is contained in:
105
src/database/model/policy.model.ts
Normal file
105
src/database/model/policy.model.ts
Normal file
@@ -0,0 +1,105 @@
|
||||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
||||
import { Types } from 'mongoose';
|
||||
|
||||
@Schema({
|
||||
timestamps: { createdAt: 'createdAt', updatedAt: 'updatedAt' },
|
||||
versionKey: false,
|
||||
collection: 'policies',
|
||||
_id: true,
|
||||
})
|
||||
export class PolicyModel {
|
||||
@Prop({ type: Types.ObjectId, required: true, index: true })
|
||||
userId: Types.ObjectId;
|
||||
|
||||
@Prop({ type: Number, required: true, index: true })
|
||||
policyId: number;
|
||||
|
||||
@Prop({ type: String, required: true })
|
||||
policyNumber: string;
|
||||
|
||||
@Prop({ type: String, required: true })
|
||||
insuranceLineName: string;
|
||||
|
||||
@Prop({ type: Number, required: true })
|
||||
insuranceLineCode: number;
|
||||
|
||||
@Prop({ type: String, required: true })
|
||||
policyHolderName: string;
|
||||
|
||||
@Prop({ type: String, required: true })
|
||||
insuredName: string;
|
||||
|
||||
@Prop({ type: String, required: true })
|
||||
policyIssueDate: string;
|
||||
|
||||
@Prop({ type: String, required: true })
|
||||
policyBeginDate: string;
|
||||
|
||||
@Prop({ type: String, required: true })
|
||||
policyEndDate: string;
|
||||
|
||||
@Prop({ type: String, required: true })
|
||||
policyStatus: string;
|
||||
|
||||
@Prop({ type: Number, required: true })
|
||||
policyStatusCode: number;
|
||||
|
||||
@Prop({ type: String, required: true })
|
||||
uniquePolicyCode: string;
|
||||
|
||||
@Prop({ type: String, required: false })
|
||||
referrerName: string;
|
||||
|
||||
@Prop({ type: String, required: false })
|
||||
issuingUnit: string;
|
||||
|
||||
@Prop({ type: String, required: false })
|
||||
policyHolderCode: string;
|
||||
|
||||
@Prop({ type: Number, required: false })
|
||||
agentCode: number;
|
||||
|
||||
@Prop({ type: String, required: true })
|
||||
policyType: string; // 'life', 'car', 'health', 'fire', 'cargo', 'equipment', 'travel', 'liability', 'personalAccident'
|
||||
|
||||
@Prop({ type: String, required: false })
|
||||
address: string;
|
||||
|
||||
@Prop({ type: String, required: false })
|
||||
licensePlate: string;
|
||||
|
||||
@Prop({ type: String, required: false })
|
||||
vehicleType: string;
|
||||
|
||||
@Prop({ type: Object, required: false })
|
||||
additionalData: Record<string, unknown>;
|
||||
|
||||
@Prop({ type: Boolean, default: true, index: true })
|
||||
isActive: boolean;
|
||||
|
||||
@Prop({ type: String, required: false, index: true })
|
||||
syncBatchId: string;
|
||||
|
||||
@Prop({ type: Date, required: false })
|
||||
lastSyncedAt: Date;
|
||||
|
||||
@Prop({ type: Date, default: Date.now })
|
||||
lastUpdated: Date;
|
||||
|
||||
@Prop({ type: Date })
|
||||
createdAt: Date;
|
||||
|
||||
@Prop({ type: Date })
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export const PolicySchema = SchemaFactory.createForClass(PolicyModel);
|
||||
|
||||
// Create compound index for efficient queries
|
||||
PolicySchema.index({ userId: 1, policyId: 1 }, { unique: true });
|
||||
PolicySchema.index({ policyId: 1 });
|
||||
PolicySchema.index({ userId: 1, policyStatusCode: 1 });
|
||||
PolicySchema.index({ userId: 1, isActive: 1 });
|
||||
PolicySchema.index({ userId: 1, syncBatchId: 1 });
|
||||
|
||||
// Made with Bob
|
||||
Reference in New Issue
Block a user