All files / logistics/schemas tracking.schema.ts

100% Statements 24/24
79.16% Branches 19/24
100% Functions 0/0
100% Lines 20/20

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 511x 1x     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: 'logistics_gps_pings' })
export class VehicleLocationPing extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true })
  vehicleId: MongooseSchema.Types.ObjectId;
 
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true })
  tripId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true })
  latitude: number;
 
  @Prop({ required: true })
  longitude: number;
 
  @Prop({ required: true })
  pingTime: Date;
 
  @Prop({ default: 0 })
  speedKph: number;
}
 
export const VehicleLocationPingSchema = SchemaFactory.createForClass(VehicleLocationPing);
VehicleLocationPingSchema.index({ vehicleId: 1, pingTime: -1 });
 
@Schema({ timestamps: true, collection: 'logistics_geofences' })
export class GeofenceDefinition extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true })
  geofenceName: string;
 
  @Prop({ required: true })
  latitude: number;
 
  @Prop({ required: true })
  longitude: number;
 
  @Prop({ required: true })
  radiusMeters: number;
}
 
export const GeofenceDefinitionSchema = SchemaFactory.createForClass(GeofenceDefinition);
GeofenceDefinitionSchema.index({ tenantId: 1, geofenceName: 1 }, { unique: true });