Attempting what seems like a fairly straightforward create using object:
var toSave = {
person_number: "rjq8900",
person_name: "john smith",
cars: [{
car_id: "fordTaurus1994",
make: "ford",
model: "taurus",
purchased: "31-Aug-15",
price: "1650"
}]
}
into schema:
var People = new Schema({
person_number: String,
person_name: String,
cars:[{
car_id: String,
make: String,
model: String,
purchased: Date,
price: Number
}]
})
via:
People.create(toSave, function(e, doc){
console.log(e);
});
And I'm getting:
errors:{
cars:{
[CastError: Cast to Array failed for value "[object Object]" at path "cars"]
}
}
Am I missing something blatantly obvious here?
EDIT Added "car_id" field to my example. My actual schema/document is large and somewhat dynamically created. I'm trying to be as precise as possible without being too accurate for disclosure purposes. I can't post actual data here.