Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { Document, Schema as MongooseSchema, Types } from 'mongoose'; @Schema({ timestamps: true, collection: 'asset_inspection_plans' }) export class AssetInspectionPlan extends Document { @Prop({ required: true, index: true }) tenantId: string; @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Asset', required: true }) assetId: Types.ObjectId; @Prop({ required: true }) planName: string; @Prop({ default: 90 }) // e.g. every 90 days frequencyDays: number; @Prop({ required: true, default: () => new Date() }) nextInspectionDue: Date; } export const AssetInspectionPlanSchema = SchemaFactory.createForClass(AssetInspectionPlan); @Schema({ timestamps: true, collection: 'asset_verification_sessions' }) export class AssetVerificationSession extends Document { @Prop({ required: true, index: true }) tenantId: string; @Prop({ required: true }) sessionName: string; @Prop({ required: true }) auditorId: string; @Prop({ default: 'scheduled' }) status: string; // 'scheduled' | 'in_progress' | 'completed' | 'reconciled' @Prop({ type: [MongooseSchema.Types.ObjectId], ref: 'Asset', default: [] }) targetAssetIds: Types.ObjectId[]; @Prop({ type: [MongooseSchema.Types.ObjectId], ref: 'Asset', default: [] }) verifiedAssetIds: Types.ObjectId[]; @Prop({ type: MongooseSchema.Types.Map, of: String, default: {} }) discrepancies: Map<string, string>; // assetId -> mismatch reason (e.g. 'wrong_location', 'damaged') } export const AssetVerificationSessionSchema = SchemaFactory.createForClass(AssetVerificationSession); AssetVerificationSessionSchema.index({ tenantId: 1, auditorId: 1 }); |