import { Model } from "mongoose"; import { MongooseModule, currentDate, } from "../helpers"; import { LocationKindType } from "../constants"; import { ADSBType } from "../types/adsb"; const ADSBLocationTypes: LocationKindType[] = [ LocationKindType.FixedWing, LocationKindType.Helicopter, ]; export interface ADSB extends ADSBType { } export default async function ADSBModule(mongoose: MongooseModule) { const { Schema } = mongoose; const modelSchema = new Schema({ _id: { type: Schema.Types.ObjectId, auto: true, }, tailNumber: { type: String, required: true, trim: true, minlength: 1, }, radioName: { type: String, default: "", }, kind: { type: String, default: "", }, type: { type: String, default: "", }, locationType: { type: String, enum: ADSBLocationTypes, required: true, default: LocationKindType.FixedWing, }, departmentId: { type: String, }, notes: { type: String, default: "", }, modifiedDate: { type: Date, default: currentDate, }, }, { autoIndex: false, }); modelSchema.index({ tailNumber: 1, }, { name: "tailNumber_1_unique", unique: true, }); return mongoose.model("ADSB", modelSchema, "massive_adsb", { overwriteModels: true }); } export interface ADSBModel extends Model { }