I have this SQL query:
SELECT SUM(TIME_TO_SEC(TIMEDIFF(IFNULL(userpresences.datefinished, NOW()), userpresences.dateadded))) FROM userpresences WHERE clientid = 12 GROUP BY userpresences.presenceid
Is there a way that I can translate this to MongoDB query? I am having trouble with Aggregate and group parameter.
Here's Go code:
groupStage := bson.D{
{"$group", bson.D{
{"_id", "$presenceid"},
{"count", bson.M{"$sum": "$datefinished"}},
}},
}
This count should return that SUM(...) from MySQL..