Created
January 19, 2019 13:07
-
-
Save feloy/99afe3bbd8e359f9d7b071982d3ad6f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package p | |
// Score represents the Score collection in Firestore | |
type Score struct { | |
Uid string | |
Name string | |
Points int | |
Details string | |
Country string | |
} | |
// NewFromFirestoreValue returns a new Score, from values in FirestoreValue | |
func NewFromFirestoreValue(v FirestoreValue) (*Score, error) { | |
var score Score | |
uid, err := v.getStringValue("uid") | |
if err != nil { | |
return nil, err | |
} | |
name, err := v.getStringValue("name") | |
if err != nil { | |
return nil, err | |
} | |
points, err := v.getIntegerValue("points") | |
if err != nil { | |
return nil, err | |
} | |
details, err := v.getStringValue("details") | |
if err != nil { | |
return nil, err | |
} | |
country, err := v.getStringValue("country") | |
if err != nil { | |
return nil, err | |
} | |
score = Score{ | |
Uid: uid, | |
Name: name, | |
Points: points, | |
Details: details, | |
Country: country, | |
} | |
return &score, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment