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.
22 lines
431 B
22 lines
431 B
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
|
|
}
|