const mongoose = require("mongoose");
const Schema = mongoose.Schema;

const userSchema = new Schema({
    email: {
        type: String,
        requried: true
    },
    phone: {
        type: String,
        required: true
    },
    DOB: {
        type: String,
        required: true
    },
    password: {
        type: String,
        required: true
    },
    profileImage:{
        type: String
    },
    fullName:{
        type: String
    },
    gender: {
        type: String,
        enum: ["Male", "Female"]
    },
    bio: {
        type: String
    },
    latitude:{
        type: Number,
    },
    longitude: {
        type: Number
    },
    locationName:{
        type: String
    },
    location:{
        type:{
            type: String,
            enum: ["Point"],
        }, 
        coordinates:{
            type: [Number]
        },
        locationName: {
            type: String
        },
        title:{
            type: String
        }
    },
    postalCode:{
        type: String
    },
    payCreateCustomerId:{
        type: String
    },
    profileCreted:{
        type: Boolean,
        default: false
    },
    isDeleted: {
        type: Boolean,
        default: false
    }
});

userSchema.index({ location: "2dsphere" });

const userModel = mongoose.model("User", userSchema);
module.exports = userModel;