Hi I'm creating sample REST api using Node, Express and Mongo. I'm using bodyParser() middle ware to parse the form data. Its working fine for simple object say
var user = {
name:'test',
age:'20'
}
req.body produce the same set of format to save it in the mongodb like.
{
name:'test',
age:'20'
}
When using complex object
var user = {
name:'test',
age:'20',
education: {
institute:"xxx",
year:2010
}
}
req.body produce different format something like
{
name:'test',
age:'20',
education[institute]: "xxx",
edcuation[year]:2010
}
I would like to get the same format which i post in the body to save them in the database. Is this the right approach or any other method available to this?
extended:true
andextended:false
and neither work. What am I missing? – Freshet