import mongoose, { Schema, Document, models } from "mongoose";
import { Base } from "./base";

interface IBuildAddressInterface extends Base, Document {
    buildNumber: string;
    doorNumber: string;
    floorNumber: string;
    commentAddress: string;
    letterAddress: string;
    shortLetterAddress: string;
    latitude: number;
    longitude: number;
    street: mongoose.Types.ObjectId;
}

const BuildAddressSchema = new Schema<IBuildAddressInterface>({
    buildNumber: { type: String, required: true },
    doorNumber: { type: String, required: true },
    floorNumber: { type: String, required: true },
    commentAddress: { type: String, required: true },
    letterAddress: { type: String, required: true },
    shortLetterAddress: { type: String, required: true },
    latitude: { type: Number, required: true },
    longitude: { type: Number, required: true },
    street: { type: Schema.Types.ObjectId, ref: "Street", required: true },
}, { timestamps: true });

const BuildAddress = models.BuildAddress || mongoose.model<IBuildAddressInterface>("BuildAddress", BuildAddressSchema);

export { BuildAddress };
export type { IBuildAddressInterface };
