-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
Hello,
We have schema in one of our collection called 'assets' as following
{
"_id" : "002992f0b34241a38f6c2336b52c480b",
"storage" : {
"size" : 0,
"sha256" : null,
"account_id" : "bab7a257b8db102d513eee5c279522aa",
"updated" : NumberLong("1439473126075068"),
"revision" :
},
"created" : NumberLong("1439473126075068"),
"subtype" : "video"
"updated" : NumberLong("1439473126075068"),
"catalog_id" : "35575220144c48e98f158cac91b5e5f9",
"payload" :
,
....
}
We want to group the documents in this collection by subtype and planning to use query something like:
db.assets.aggregate({ $match: { catalog_id: "35575220144c48e98f158cac91b5e5f9", deleted: {$exists: false}}} , { $group:
{ _id: "$subtype"}});
However, the "subtype" field may not be present in all the documents and we want to group such documents under one category (images). How can we achieve this using aggregation framework ?