I made this mongoose schema with a nested array of subdocuments:
const deliverySchema = new db.Schema({
price: Number
})
const suppliersSchema = new db.Schema({
name: String,
deliveries: [deliverySchema]
})
exports.Suppliers = db.model('Suppliers', suppliersSchema)
const suppliers = new Suppliers({name})
await suppliers.save()
But when I try to save a document i get this error:
TypeError: Cannot read properties of undefined (reading 'length')
at cloneArray...
If I remove the subdocument from the schema the document gets saved without issues.
Why can’t I save the document with this schema?