Thomas Simonini Thomas Simonini - 1 year ago 130
Node.js Question

Mongoose schema with object

I try to fill a document in MongoDB with NodeJS, consequently I created a Schema and a post req.

var gameSchema = new Schema({
title: String,
developer: {
name: String,
email: String
isBroadcasted: Boolean

So I want to populate this schema thanks to a req.'/android', auth, function(req, res){
// Create a new instance of the Game model
var game = new Game();
game.title = req.body.title; =; =;

enter image description here

But, when I run it there is an error message "TypeError: Cannot read property 'name' of undefined" but I don't understand why because exists.

Answer Source

I guess the error is not referring to but to
Try changing your line to = req.body['']

as your parameter is parsed as string, not as nested object.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download