I have some Mongo data of the form:
{
"content": "Foo",
"metadata": {
"key1": "value",
"key2": "another value",
"key3": "and another value"
}
}
The keys in the metadata subdocument could be named anything (I've called them key1
, key2
and key3
above, but they could be called author
, title
and date
for example). There will be an unknown number of them, and the names may also be unknown.
Is there an (aggregation?) query I can run to list all of the fields in the metadata subdocument, across all of the documents in my collection?