Encountering issues with Mongoose Required true and Enum validation when using updateone
await MonthlyTarget.updateOne({website: req.body.website, year: req.body.year, month: req.body.month}, req.body, {upsert: true});
Model
'use strict';
import pkg from 'mongoose';
const { Schema, model } = pkg;
const monthlyTargetSchema = new Schema({
website: { type: Schema.Types.ObjectId, ref:'Websites', index: true, required: true },
category: { type: Schema.Types.ObjectId, ref:'IncidentCategory', index: true, required: true },
year: { type: String, index: true },
month: { type: String, required: true, enum:['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'], index: true },
target: { type: Schema.Types.Number, index: true },
});
const MonthlyTarget = model('MonthlyTarget', monthlyTargetSchema);
export default MonthlyTarget;