Adding child document to existing mongodb document
The error you are getting is as a result of embedding the Adventure
model instead of the schema. You need to add the Adventure
schema in the destination schema definition the Adventure
model's schema property:
// this is the "destination" model for mongoosevar mongoose = require('mongoose');var AdventureSchema = require('../models/adventure').schema; /* <- access the schema via its Model.schema property */var tripSchema = mongoose.Schema({ name: { type: String, required: true }, city: { type: String, required: true }, dateStart: { type: Date, required: true }, dateFinish: { type: Date, required: true }, adventures: [AdventureSchema]});