javascript - Mongoose: Cannot call method 'push' of undefined, on nested Schema -
i set schema so:
var videoschema = new schema({ title: string, url: string, //link video rating: { type: number, default: 0}, description: string //a paragraph or 2 go along 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);
add document so:
var newpage = new models.tutorialpage({ title: req.query.page.title, tutorials: [] }); parentcategory.pages.push(newpage);
in return, gives me nice "typeerror: cannot call method 'push' of undefined "
other times question asked, people didn't load schemas in correct order or conflated model schema when setting schema up, doesn't seem problem. gives?
Comments
Post a Comment