I have 2 collections, Country and cities, cities should hold the ObjectId reference of Countries,
On Creation of new city,
i want cities Collection should Look like
{
"_id" : ObjectId("5c83505e5609a7274855ae4c"),
"city_id" : "13456",
"city_name" : "CapeTown",
"country" :ObjectId("5c8350235609a7274855ae4b")
"_class" : "com.mycompany.myapp.domain.cities"
}
I don't want something like
{
"_id" : ObjectId("5c83505e5609a7274855ae4c"),
"city_id" : "13456",
"city_name" : "CapeTown",
"country" : {
"$ref" : "countries",
"$id" : ObjectId("5c8350235609a7274855ae4b")
},
"_class" : "com.mycompany.myapp.domain.cities"
}
How to write the model class to achieve my requirement?