I created one schema in mongodb its very nested schema. It looks like this
{
"_id": ObjectID("559690ec34c506cea4be1775"),
"cities": [
{
"val": "something",
"pincode": [
{
"val": "something",
"people": [
{
"val": "something",
"frnds": [
{
"val": "something1",
"frndaddress": [
{
"val": "something2"
}
]
}
]
}
]
}
]
}
]
}
This document is inserted properly in mongodb but I don't have any idea about how I can convert this is on mongoose I try this one with mongoose but its seems its not working
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// create a all city list, without id
var allCitySchema = new Schema({
cities: [{
val:{ type: String },
pincode:[{
val:{ type: String },
people:[{
val:{ type: String },
frnds:[{
val:{ type: String },
frndaddress:[{
val:{ type: String },
}]
}]
}]
}]
}]
}, {collection: 'allcities'});
var allcities = mongoose.model('allcities', allCitySchema);
module.exports = allcities;
I am new on node and mongodb I created above schema I even don't know its correct or not.