In the code below, the commented email schema was the previous, I no longer want the email to be required, and unique, it should be optional.
I get an error saying duplicate, of null "E11000 duplicate key error collection: mydb.lists index: email_1 dup key: (email: null)"
const mongoose = require("mongoose");
const { Schema } = mongoose;
const alliedSchema = new Schema(
{
name: String,
phone: String,
email: {
unique: false,
type: String
},
// email:{
// type: String,
// unique: true,
// required: true,
// lowercase: true,
// validate(value){
// if(!validator.isEmail(value)){
// throw new Error('Email is invalid')
// }
// }
// },
picture: {
type: String,
default: "https://www.dialadocdirect.org/app/storage/images/noimage.jpg",
},
location: String,
type: String,
verified: {
type: Boolean,
default: false,
},
},
{
timestamps: true,
}
);
module.exports = mongoose.model("allied", alliedSchema);