const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const mongodbErrorHandler = require('mongoose-mongodb-errors');
const userSchema = new Schema({
name: {
type: String,
},
phoneNumber: {
type: String,
trim: true,
unique: true,
required: true
},
password: {
type: String,
trim: true,
},
email: {
type: String,
required:true
},
}, {
toJSON: {
virtuals: true
},
toObject: {
virtuals: true
},
timestamps: true
});
//userSchema.plugin(mongodbErrorHandler);
userSchema.index({
userId: 1
});
module.exports = mongoose.model('User', userSchema);