My Mongoose model is:
var Schema = new Schema({
code: String,
type: String,
people:{}
}
and data for items is :
people :
{
"id":"2342423",
"name":"John"
},
{
"id":"1231231",
"name":"Marry"
}
when I write:
var obj = new Schema({
people:people});
obj.people is {}. Where am I wrong?
people should be of type Object or Array
What you have isn't valid JSON. The top level needs to be a single object or array, so you might want something like the following:
people: [
{
"id":"2342423",
"name":"John"
},
{
"id":"1231231",
"name":"Marry"
}
]
That's a single array, containing objects that have information about two people.