const mongoose = require('mongoose') const ObjectID = mongoose.Schema.Types.ObjectId const belongingSchema = new mongoose.Schema( { belongingCode: { type: String, required: true, unique: true, }, belongingCategory: { type: ObjectID, ref: 'Category' }, projectCode: { type: String, required: true, default: false, }, relatedProjects : [String], location: { type: { type: String, enum: ['Point'], // GeoJSON type required: true, }, coordinates: { type: [Number], // Array of numbers: [longitude, latitude] required: true, }, }, documents: [String] }, { timestamps: true } ) belongingSchema.index({ location: '2dsphere' }); // Enable geospatial queries const Belonging = mongoose.model('Belonging', belongingSchema) module.exports = Belonging