connect(connectionString); await mongoose.connection.dropDatabase(); mongoose.model('Item', new mongoose.Schema({ name: { type: String } })); const schema = new mongoose.Schema({ name: { type: String, required: true }, items: { type: [{ type: mongoose.Schema.Types.ObjectId, ref: ...
I have a schema with two required arrays. It seems that mongoose is defaulting the first array to an empty array and only performing validation on the second one (by first and second I mean ordering of the schema objects. For example: 'u...
upsert === true) { schema.requiredPaths().map(p => { if (!(update[p] || update.$set[p])) { let str = `path '${p}' is required with upsert === true`; return next(new Error(str)); } }); } next(); }); const Test = mongoose.model('test', schema); async function ...