Reputation: 559
I have this document structure:
{
"a":{
"b":{
"c":"Eduardo","d":"Romero"
}
}
}
How do I get this results in mongodb language?
{"c":"Eduardo","d":"Romero"}
Thank very much in advance
Upvotes: 1
Views: 55
Reputation: 49945
You need $replaceRoot pipeline stage, try:
db.col.aggregate([ { $replaceRoot: { newRoot: "$a.b" } } ])
Upvotes: 1