import {Schema}from'mongoose';const countryModelSchema = new Schema({
    name: { type: Schema.Types.String, required: true, maxlength: 50, unique: true },
    phone_code: { type: Schema.Types.String },
    currency: { type: Schema.Types.String },
    currency_symbol: { type: Schema.Types.String },
    emoji: { type: Schema.Types.String },
    location: {
        type: {
            type: Schema.Types.String,
            default: 'Point',
            enum: ['Point'], // 'location.type' must be 'Point'
        },
        coordinates: {
            type: [Schema.Types.Number],
            required: true,
        },
    },
    _id: { type: Schema.Types.String, required: true, unique: true },
}, {
    _id: false,
    versionKey: false,
});
countryModelSchema.virtual('id').get(function () {
    return this._id;
});
countryModelSchema.set('toJSON', {
    virtuals: true,
});
countryModelSchema.set('toObject', {
    virtuals: true,
});
countryModelSchema.index({ name: 1, phone_code: 1 }, { unique: true });
countryModelSchema.index({ location: '2dsphere' });
const CountryModelFunc = (db) => db.model('countries', countryModelSchema);export{CountryModelFunc};