Учитывая эту схему:
{
"_id" : ObjectId("5b8d29d239bd595000edf3ee"),
"role" : [
{
"role_id" : "599adabbef17f85afbcee00d",
"earn" : {
"5943c3f7c74b036a883efaf5" : "E2",
"5943c46ec74b036a883efaf1" : "E0",
"594a0b08c74b030a2ae33cce" : "E2",
"5943c3f7c74b036a883efaf0" : "E5",
"5943c46ec74b036a883efab1" : "E0",
"594a0b08c74b030a2ae34cce" : "E4"
}
},
{
"role_id" : "599adabbef17f85afbcee02d",
"earn" : {
"6943c3f7c74b036a883efaf5" : "E2",
"6943c46ec74b036a883efaf1" : "E0",
"694a0b08c74b030a2ae33cce" : "E2",
"6943c3f7c74b036a883efaf0" : "E5",
"6943c46ec74b036a883efab1" : "E0",
"694a0b08c74b030a2ae34cce" : "E4"
}
}
]
}
Попробуйте это ниже агрегации
{
"_id" : ObjectId("5b8d29d239bd595000edf3ee"),
"role" : [
{
"role_id" : "599adabbef17f85afbcee00d",
"earn" : {
"5943c3f7c74b036a883efaf5" : "E2",
"5943c46ec74b036a883efaf1" : "E0",
"594a0b08c74b030a2ae33cce" : "E2",
"5943c3f7c74b036a883efaf0" : "E5",
"5943c46ec74b036a883efab1" : "E0",
"594a0b08c74b030a2ae34cce" : "E4"
}
},
{
"role_id" : "599adabbef17f85afbcee02d",
"earn" : {
"6943c3f7c74b036a883efaf5" : "E2",
"6943c46ec74b036a883efaf1" : "E0",
"694a0b08c74b030a2ae33cce" : "E2",
"6943c3f7c74b036a883efaf0" : "E5",
"6943c46ec74b036a883efab1" : "E0",
"694a0b08c74b030a2ae34cce" : "E4"
}
}
]
}
вернет:
{
"5943c3f7c74b036a883efaf5" : "E2",
"594a0b08c74b030a2ae33cce" : "E2",
"5943c3f7c74b036a883efaf0" : "E5",
"594a0b08c74b030a2ae34cce" : "E4",
"6943c3f7c74b036a883efaf5" : "E2",
"694a0b08c74b030a2ae33cce" : "E2",
"6943c3f7c74b036a883efaf0" : "E5",
"694a0b08c74b030a2ae34cce" : "E4"
}
Надеюсь, это поможет ...