import { model, Schema, Types } from "mongoose"; import { locationSchema } from "../../helpers"; const schema = new Schema({ user: { type: Types.ObjectId, required: true, ref: "user", }, coordinates: locationSchema, createdOn: { type: Date, required: true, }, venue: { type: Types.ObjectId, required: false, ref: "venue", }, }); schema.index({ coordinates: "2dsphere" }); export default model("location", schema);