是否可以在另一个猫鼬模式中嵌入嵌入式外部猫鼬模式?

问题描述

是否可以制作一组外部猫鼬模式? 当我这样运行时,控制台会说:

TypeError: Invalid value for schema Array path `comments`,got value "undefined"

comment.js

const mongoose = require('mongoose');

const commentScheme = new mongoose.Schema({
    body: String,author: {
        id: { type: mongoose.Schema.Types.ObjectId,ref: 'User' },username: String
    }
});

module.exports = mongoose.model('Comment',commentScheme);

campground.js

const mongoose = require('mongoose'),Comment = require('./comment');

const campgroundSchema = new mongoose.Schema({
    name: String,image: String,desc: String,comments: [ Comment.commentSchema ]
});

module.exports = mongoose.model('Campground',campgroundSchema);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)