本质上,我只是尝试将新的子文档添加到具有以下模式的现有mongodb文档中
/models/server/destination.js
// this is the "destination" model for mongoose
var mongoose = require('mongoose')
var Adventure = require('../models/adventure')
// this is the schema that every entry will get when a new trip is made.
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: [Adventure]
})
// module.exports makes this model available to other file
module.exports = …Run Code Online (Sandbox Code Playgroud)