Ive used MySQL since I was a young boy and now I have to switch to MongoDB for various reasons.
I write a log which saves every php error in a MongoDB collection. Reading out the errors is not the problem, using a simple find() is pretty easy and it's great that you can use php arrays to get to the data.
Now I want to have some statistics about the errors. My Collection looks like so:
{
"_id": ObjectId("51af10ca0e5e723c0a000000"),
"Errors": {
"2048": {
"0": {
"Message": "Declaration of ADODB_mysqli::MetaIndexes() should be compatible with ADOConnection::MetaIndexes($table, $primary = false, $owner = false)",
"File": "File.php",
"Line": NumberInt(29),
"Time": NumberInt(1370427591)
}
},
"2": {
"0": {
"Message": "Error",
"File": "File.php",
"Line": NumberInt(29),
"Time": NumberInt(1370427591)
},
"1": {
"Message": "Error",
"File": "File.php",
"Line": NumberInt(29),
"Time": NumberInt(1370427591)
}
},
"8": {
"0": {
"Message": "Undefined index: PluginLastAdded",
"File": "File.php",
"Line": NumberInt(36),
"Time": NumberInt(1370427594)
},
"1": {
"Message": "Undefined index: PluginLastAdded",
"File": "File.php",
"Line": NumberInt(36),
"Time": NumberInt(1370427594)
}
}
}
}
Now I want to know how often each error in this entry occours. It would be great to have a seperated list into 2048, 2, 8 and then the count of each error.
Is that possible without much php code but using MongoDB's aggregation?
Any help would be great, MongoDB is 180° different than MySQL in my opinion, and the switch is pretty hard.