All files / visitor/schemas facility.schema.ts

100% Statements 23/23
80% Branches 12/15
100% Functions 0/0
100% Lines 19/19

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 481x 1x     1x   1x     1x     1x     1x     1x     1x     1x 1x     1x   1x     1x     1x     1x     1x     1x 1x  
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Schema as MongooseSchema } from 'mongoose';
 
@Schema({ timestamps: true, collection: 'visitor_facility_locations' })
export class VisitorFacilityLocation extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true })
  campusName: string;
 
  @Prop({ required: true })
  buildingName: string;
 
  @Prop({ required: true })
  floorName: string;
 
  @Prop({ default: '' })
  wingName?: string;
 
  @Prop({ required: true })
  locationCode: string; // e.g. "BLDG-A-FLR-2"
}
 
export const VisitorFacilityLocationSchema = SchemaFactory.createForClass(VisitorFacilityLocation);
VisitorFacilityLocationSchema.index({ tenantId: 1, locationCode: 1 }, { unique: true });
 
@Schema({ timestamps: true, collection: 'visitor_facility_rooms' })
export class VisitorFacilityRoom extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'VisitorFacilityLocation', required: true, index: true })
  locationId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true })
  roomName: string;
 
  @Prop({ required: true, index: true })
  roomType: string; // 'Meeting Room' | 'Conference Room' | 'Training Room' | 'Cabin' | 'Hot Desk'
 
  @Prop({ type: [MongooseSchema.Types.ObjectId] })
  associatedAssetIds: MongooseSchema.Types.ObjectId[]; // References central Asset collection
}
 
export const VisitorFacilityRoomSchema = SchemaFactory.createForClass(VisitorFacilityRoom);
VisitorFacilityRoomSchema.index({ tenantId: 1, locationId: 1, roomName: 1 }, { unique: true });