My database has following type of documents for Categories collection.
{
"_id" : ObjectId("56716afa403743492828aa07"),
"cat_name" : "watches",
"cat_parent_id" : [
ObjectId("56716afa403743492828aa01"),
ObjectId("56716afa403743492828aa03")
]
.........
}
I first created database with Robomongo, then I'm trying to fetch data using mongoose and created following Schema.
var categorySchema = new Schema({
'cat_name' : String,
'cat_parent_id' : [{ type : mongoose.Types.ObjectId }],
.......
});
but when I'm getting the result through following callback,
Categories.find(function(err,categories){........});
the cat_parent_id array is empty.
Edit:
When I replace mongoose.Types.ObjectId with Schema.Types.ObjectId or String,It works.Can anyone provide reason for that?