All files / logistics/schemas network.schema.ts

100% Statements 20/20
80% Branches 8/10
100% Functions 0/0
100% Lines 16/16

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 391x 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_networks' })
export class LogisticsNetwork extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true })
  networkCode: string;
 
  @Prop({ required: true })
  networkName: string;
}
 
export const LogisticsNetworkSchema = SchemaFactory.createForClass(LogisticsNetwork);
LogisticsNetworkSchema.index({ tenantId: 1, networkCode: 1 }, { unique: true });
 
@Schema({ timestamps: true, collection: 'logistics_hubs' })
export class LogisticsHub extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true })
  hubCode: string;
 
  @Prop({ required: true })
  hubName: string;
 
  @Prop({ required: true })
  address: string;
 
  @Prop({ required: true })
  nodeType: string; // 'Warehouse' | 'Distribution center' | 'Cross-dock' | 'Plant'
}
 
export const LogisticsHubSchema = SchemaFactory.createForClass(LogisticsHub);
LogisticsHubSchema.index({ tenantId: 1, hubCode: 1 }, { unique: true });