Change mapreduce to aggregate in device auth

I am trying to use mongo atlas as a database, but they do not allow mapreduce on their smaller tiers. so line 835 in datastore_mongo.go (https://github.com/mendersoftware/deviceauth/blob/master/store/mongo/datastore_mongo.go#L835) fails. I am not any good with go but i think i read it as take the collection and filter by device_id given in the api call and then map reduce the return a sum of the statuses, but wouldnt that always return just one status not making mapreduce needed? or could i use this code instead?

	pipeline := []bson.M{
	bson.M{
		"$match": filter,
	},
	bson.M{
		"$group": bson.M{
			"_id": "$status", "total": 
			bson.M{
				"$sum": 1,
			},
		},
	},
}
err := c.Pipe(pipeline).All(&result)