我有2个集合,“国家和城市”,城市应持有“国家/地区”的ObjectId引用,
关于创建新城市,
我希望城市收藏集看起来像
{
"_id" : ObjectId("5c83505e5609a7274855ae4c"),
"city_id" : "13456",
"city_name" : "CapeTown",
"country" :ObjectId("5c8350235609a7274855ae4b")
"_class" : "com.mycompany.myapp.domain.cities"
}
我不想要类似的东西
{
"_id" : ObjectId("5c83505e5609a7274855ae4c"),
"city_id" : "13456",
"city_name" : "CapeTown",
"country" : {
"$ref" : "countries",
"$id" : ObjectId("5c8350235609a7274855ae4b")
},
"_class" : "com.mycompany.myapp.domain.cities"
}
如何编写模型类以满足我的要求?