mongodb - Aggregation on subdocuments with unknown key names -


i have collection of documents following structure:

"_id" : "20130104/activity", "hourly" : {     "0" : {         "activity1" : 25,         "activity2" : 10     },     "1" : {         "activity1" : 25,         "activity2" : 10,         "activity3" : 5     },     "2" : {         "activity1" : 25,         "activity2" : 10,         "activity3" : 5     }     } 

i able aggregate data able generate monthly , daily statistics document shown here:

"date" : "20130104", "total" : {         "activity1" : 75,         "activity2" : 30,         "activity3" : 10           } 

my problem not know key names in hourly subdocument beforehand - makes using aggregate framework quite hard. (or maybe misunderstood something).

any suggestions?

map reduce can used here calculate reporting data , not need know name of key. 1 approach have 24 hours day , can have document 24 hours key , can use aggregation framework . approach give performance boost , common pattern


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -