Answer the question
In order to leave comments, you need to log in
How to properly create an entry along with child elements?
There are two circuits (details omitted for simplicity):
const parentSchema = new mongoose.Schema({
title: {
type: String,
required: false
},
childs: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'Child'
}]
});
const Parent = mongoose.model('Parent, parentSchema);
const childSchema = new mongoose.Schema({
title: {
type: String,
required: false
},
description: {
type: String,
required: false
}
});
const Child = mongoose.model('Child', childSchema);
const newCalendar = new Calendar({
titles: "asd",
childs: [
{
title: "child1",
description: "description1"
}
]
});
return newCalendar.save();
Parent validation failed: childs: Cast to Array failed for value \"[ {тут переданные поля} ]\" at path \"childs\""
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question