GraphQL API and utilities for the rpdata project
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

  1. package unknownnicks
  2. import (
  3. "github.com/globalsign/mgo/bson"
  4. )
  5. // Update updates the map, replacing it with the scores provided here.
  6. func Update(updateMap map[string]int) error {
  7. _, err := collection.RemoveAll(bson.M{})
  8. if err != nil {
  9. return err
  10. }
  11. for nick, score := range updateMap {
  12. _, err := collection.UpsertId(nick, bson.M{"$set": bson.M{"score": score}})
  13. if err != nil {
  14. return err
  15. }
  16. }
  17. return nil
  18. }