相关疑难解决方法(0)

将子文档添加到现有mongodb文档

本质上,我只是尝试将新的子文档添加到具有以下模式的现有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)

addchild mongoose mongodb mean-stack mongoose-schema

13
推荐指数
1
解决办法
3393
查看次数