You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
package main
|
|
|
|
import "gopkg.in/mgo.v2/bson"
|
|
|
|
func getStats() StatsModel {
|
|
var stats StatsModel
|
|
err := statsCollection.Find(bson.M{"title": "stats"}).One(&stats)
|
|
check(err)
|
|
stats.Title = "stats"
|
|
return stats
|
|
}
|
|
|
|
func updateStats(stats StatsModel) {
|
|
var oldStats StatsModel
|
|
err := statsCollection.Find(bson.M{"title": "stats"}).One(&oldStats)
|
|
if err != nil {
|
|
err = statsCollection.Insert(stats)
|
|
check(err)
|
|
} else {
|
|
err = statsCollection.Update(bson.M{"title": "stats"}, &stats)
|
|
check(err)
|
|
}
|
|
}
|