Reputation: 2570
I have the following document:
{
value: {
a: 1,
b: 'yellow',
c: {'foo': 'baz'}
}
}
How can I transform it to
{
a: 1,
b: 'yellow',
c: {'foo': 'baz'}
}
Note: I don't want to project each and every field manually. I'm looking for an automatic way to do it
Thanks!
Upvotes: 1
Views: 504
Reputation: 730
I think you are looking for $replaceRoot. Try this playground.
{
"$replaceRoot": {
"newRoot": "$value"
}
}
More info in docs.
Upvotes: 3