import { model, Schema, Types } from "mongoose"; import { locationSchema } from "../../helpers"; const contactPersonSchema = new Schema({ name: { type: String, required: true, }, email: { type: String, required: true, }, mobile: { type: String, required: true, }, designation: { type: String, required: true, }, }); const schema = new Schema({ name: { type: String, required: true, }, createdBy: { type: Types.ObjectId, required: true, ref: "user", }, createdOn: { type: Date, required: true, }, address: { type: String, required: true, }, city: { type: String, required: true, }, state: { type: String, required: true, }, pincode: { type: String, required: true, }, location: locationSchema, category: { type: String, required: true, default: "OWN", enum: ["OWN", "PARTNER", "VENDOR", "CLIENT", "DISTRIBUTOR"], }, type: { type: String, required: true, enum: ["HQ", "BRANCH", "WAREHOUSE"], }, entity: { type: Types.ObjectId, required: false, }, contactPerson: { type: contactPersonSchema, required: false, }, }); schema.index({ location: "2dsphere" }); export default model("venue", schema);