import mongoose, { Document, Schema } from 'mongoose';

export interface Farm extends Document {
    farmer?: string;
    locality: string;
    name: string;
}

const FarmSchema = new Schema<Farm>(
    {
        farmer: { type: String },
        locality: { type: String, required: true },
        name: { type: String, required: true },
    },
    {
        minimize: true,
        timestamps: true,
    },
);

export default mongoose.models?.Farm || mongoose.model<Farm>('Farm', FarmSchema);
