Add Model for backend

This commit is contained in:
2025-02-22 15:20:35 +05:30
parent fe2cd31200
commit 1fdb739950
13 changed files with 115 additions and 153 deletions
+21
View File
@@ -0,0 +1,21 @@
const mongoose = require("mongoose");
const cropSchema = new mongoose.Schema(
{
name: { type: String, required: true },
farm: { type: mongoose.Schema.Types.ObjectId, ref: "Farm", required: true },
plantedDate: { type: Date, required: true, default: Date.now() },
harvestDate: { type: Date },
growthStage: {
type: String,
enum: ["Planted", "Growing", "Ready to Harvest"],
default: "Planted",
},
healthStatus: { type: String, default: "Healthy" },
},
{ timestamps: true }
);
const Crop = mongoose.model("Crop", cropSchema);
module.exports = Crop;