func addKeyInDatabase(key *auth.Key, u *auth.User) error { conn, err := db.Conn() if err != nil { return err } defer conn.Close() u.AddKey(*key) return conn.Users().Update(bson.M{"email": u.Email}, u) }