【发布时间】:2017-09-11 18:34:18
【问题描述】:
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var ObjectId = Schema.ObjectId;
var Comment = mongoose.model('Comment', new Schema({
title : String,
body : String,
date : Date
}))
var Post = mongoose.model('Post', new Schema({
comments : [Comment]
}))
module.exports.Comment = Comment
module.exports.Post = Post
按照一个简单应用程序的教程,在尝试创建其他东西并学习 Mongoose 模式时,我在尝试使用嵌入文档时遇到错误,就像以前的应用程序定义模型的方式一样
我收到了这个错误
throw new TypeError('Undefined type
' + name + 'at array `' + path +
TypeError:未定义类型 model 位于数组 comments
【问题讨论】:
标签: javascript mongoose mongoose-schema