site.schema.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**
  2. * * **Current State:** The `Block` schema class model contains a `phaseCode` indexed lookup string that dynamically links blocks to phases.
  3. * * **Intended Mutation:** Delete the `@Prop` declaration and property for `phaseCode` in the `Block` class (lines 45-46) to achieve a flat schema state.
  4. * * **Risk Mitigation:** Cross-entity validation is entirely shifted to the `FFB Production` ledger level, making the master block seeder 100% independent.
  5. */
  6. import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
  7. import { Document } from 'mongoose';
  8. export type PhaseDocument = Phase & Document;
  9. @Schema()
  10. export class Phase {
  11. _id?: string;
  12. @Prop({ type: Number, required: true })
  13. locId: number;
  14. @Prop({ type: String, required: true, unique: true })
  15. phaseCode: string;
  16. @Prop({ type: String })
  17. description: string;
  18. @Prop({ type: String })
  19. locType: string;
  20. blocks?: Block[];
  21. }
  22. export const PhaseSchema = SchemaFactory.createForClass(Phase);
  23. export type BlockDocument = Block & Document;
  24. @Schema()
  25. export class Block {
  26. _id?: string;
  27. @Prop({ type: Number, required: true })
  28. locId: number;
  29. @Prop({ type: String, required: true, unique: true })
  30. blockCode: string;
  31. @Prop({ type: String })
  32. blockDesc: string;
  33. @Prop({ type: String })
  34. locType: string;
  35. @Prop({ type: Number })
  36. entryNo: number;
  37. @Prop({ type: Number })
  38. entryYear: number;
  39. @Prop({ type: Number })
  40. quarterPlanted: number;
  41. @Prop({ type: String })
  42. monthPlanted: string;
  43. @Prop({ type: Number })
  44. totalTrees: number;
  45. @Prop({ type: Number })
  46. totalMaturedTrees: number;
  47. @Prop({ type: Number })
  48. totalImmaturedTrees: number;
  49. @Prop({ type: Number })
  50. totalDeadTrees: number;
  51. @Prop({ type: Number })
  52. plantedArea: number;
  53. @Prop({ type: Number })
  54. initialPlantedArea: number;
  55. @Prop({ type: String })
  56. plantedLocUOM: string;
  57. @Prop({ type: String })
  58. soilCondition: string;
  59. }
  60. export const BlockSchema = SchemaFactory.createForClass(Block);