My model:
Email_Sender: {
type: String,
trim: true,
required: true
},
Email_Receiver: {
type: String,
trim: true,
required: true
},
Message: [{
msg: {
type: String,
trim: true
},
Date: {
type: String,
trim: true
},
Email: {
type: String,
trim: true
}
}]
const get_save_chat_emais = new chat({
Email_Sender : s_email,
Email_Receiver: r_email,
Message: [{
msg : message,
Date : date,
Email : r_email
}]
});
await get_save_chat_emais.save();
MongoError: E11000 duplicate key error collection: chat_database.chats index: Email_Sender_1 dup key: { Email_Sender: "[email protected]" }
- I do not use unique: true but getting duplicate error on email*