const mongoose = require('mongoose'); const { Schema } = mongoose; const pointSchema = new Schema({ type: { type: String, enum: ['Point'], required: true }, coordinates: { type: [Number], required: true } }); const schema = new Schema({ first_name: { type: String }, last_name: { type: String }, middle_name: { type: String }, email: { type: String, unique: true, lowercase: true }, password: { type: String }, phone: { type: String }, phone2: { type: String }, permissions: [{ type: String, default: 'role_admin' }], gender: { type: String }, address: { type: String }, dob: { type: String }, // vehicle_status: { type: String, enum: ['Free', 'Loading', 'Moving', 'Downloading'] }, job_role: { type: String }, // admin, owner, driver, staff employee_id: { type: String }, //EM-1000-1 EM-1000-2 company: { type: Schema.Types.ObjectId, ref: 'companies' }, branch: { type: Schema.Types.ObjectId, ref: 'branches' }, vehicle: { type: Schema.Types.ObjectId, ref: 'vehicles' }, active_load: { type: Schema.Types.ObjectId, ref: 'loads' }, categories: [{ type: Schema.Types.ObjectId, ref: 'product-categories' }], user_city: [{ type: String }], user_state: [{ type: String }], user_description: { type: String }, truck_type: [{ type: String }], last_location_lat: { type: String }, last_location_lng: { type: String }, last_location_geo: { type: pointSchema }, last_location_time: { type: Date }, isVerified: { type: Boolean }, verifyToken: { type: String }, verifyShortToken: { type: String }, verifyExpires: { type: Date }, // or a long integer verifyChanges: { type: Object }, // an object (key-value map), e.g. { field: "value" } resetToken: { type: String }, resetShortToken: { type: String }, resetExpires: { type: Date }, // or a long integer resetAttempts: { type: Number }, is_hidden: { type: Boolean, default: false }, }); module.exports = mongoose.model( "users", schema );