Javascript Mongoose:无法调用方法';推动';对于未定义的,在嵌套架构上

Javascript Mongoose:无法调用方法';推动';对于未定义的,在嵌套架构上,javascript,node.js,mongodb,mongoose,Javascript,Node.js,Mongodb,Mongoose,我的模式设置如下: var videoSchema = new Schema({ title: String, url: String, //Link to the video rating: { type: Number, default: 0}, description: String //a paragraph or two to go along with the video }); var tutorialPageSchema = new Schema

我的模式设置如下:

var videoSchema = new Schema({
    title: String,
    url: String, //Link to the video
    rating: { type: Number, default: 0},
    description: String //a paragraph or two to go along with the video
});

var tutorialPageSchema = new Schema({
    title: String, //IE Peeking, Clutching, etc.
    tutorials: [videoSchema]
});

var categorySchema = new Schema({
    title: String, //intermediate, beginner, config, map knowledge, etc.
    pages: [tutorialPageSchema]
});

exports.Video = mongoose.model('video', videoSchema);
exports.TutorialPage = mongoose.model('tutorialPage', tutorialPageSchema);
exports.Category = mongoose.model('category', categorySchema);
按如下方式添加文档:

var newPage = new models.TutorialPage({
    title: req.query.page.title,
    tutorials: []
});
parentCategory.pages.push(newPage);
作为回报,它给了我一个很好的“TypeError:无法调用undefined的方法‘push’” "


其他时候有人问这个问题,人们没有按照正确的顺序加载模式,或者在设置模式时将模型与模式混为一谈,但这似乎不是我的问题。提供了什么?

parentCategory没有pages属性。什么是parentCategory以及如何获得它。models.Category.find({title:req.query.page.Category}),function(err,parentCategory){console.log(parentCategory)的输出是什么?[{u id:55407995e230cc0c18326167,title:'初学者',v:0,pages:[}]我用一个空数组初始化了页面,就像我用“教程:[]'如果这有什么区别。您得到的是数组而不是对象。如果希望只得到一个类别,则应使用findOne。您当前的代码将用于parentCategory[0]。pages.push。。。。