请参阅post 如何使用Java将数组添加到MongoDB文档?
我已经使用java创建了一个mongo架构,它有子元素,我得到_id的主文档我想_id在子元素中也在这里输出看起来(我已经标记了我需要的部分_id) b.party.find().pretty();
{
"_id" : ObjectId("5399aba6e4b0ae375bfdca88"),
"addressDetails" : [
{
// _id here
"locationName" : "Office",
"phones" : [
{ // _id here
"name" : "Tel1",
"value" : "95253-"
},
{ // _id here
"name" : "Tel2",
"value" : "95253-"
},
{ // _id here
"name" : "Tel3",
"value" : "95253-"
},
{ // _id here
"name" : "Fax1",
"value" : "0253-"
}
],
"address" : "A-3,MIDCA-3,MIDC",
"defaultBillAddrerss" : "",
"pincode" : …Run Code Online (Sandbox Code Playgroud)