Files
api/models/unknownnicks/update.go
T

23 lines
431 B
Go

package unknownnicks
import (
"github.com/globalsign/mgo/bson"
)
// Update updates the map, replacing it with the scores provided here.
func Update(updateMap map[string]int) error {
_, err := collection.RemoveAll(bson.M{})
if err != nil {
return err
}
for nick, score := range updateMap {
_, err := collection.UpsertId(nick, bson.M{"$set": bson.M{"score": score}})
if err != nil {
return err
}
}
return nil
}