plantation.node.schema.ts 926 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
  2. import { Document, Types } from 'mongoose';
  3. import { Worker, WorkerSchema } from './worker.schema';
  4. export type PlantationNodeDocument = PlantationNode & Document;
  5. @Schema()
  6. export class PlantationNode {
  7. @Prop({ required: true, unique: true })
  8. id: string;
  9. @Prop({ required: true })
  10. name: string;
  11. @Prop()
  12. location?: string;
  13. @Prop()
  14. plantedDate?: Date;
  15. @Prop({ enum: ['ROOT','SITE','ZONE','BLOCK','TREE'], default: 'BLOCK' })
  16. type: string;
  17. @Prop({ enum: ['ACTIVE','INACTIVE','MAINTENANCE'], default: 'ACTIVE' })
  18. status: string;
  19. @Prop({ default: '' })
  20. notes?: string;
  21. @Prop({ type: [WorkerSchema], default: [] })
  22. workers: Worker[];
  23. @Prop({ type: [Types.ObjectId], ref: 'PlantationNode', default: [] })
  24. childrenNode: PlantationNode[];
  25. }
  26. export const PlantationNodeSchema = SchemaFactory.createForClass(PlantationNode);