Open
Description
Describe your environment
- Operating System version: all
- Firebase SDK version: v3.13.0
- Firebase Product: database
Describe the problem
The serverside timestamp value is a unique field in Firebase databases, as it's uploaded with the json { ".sv" : "timestamp" }
and then converted to a timestamp on the serverside.
The javascript realtime database sdk has a constant called firebase.database.ServerValue.TIMESTAMP for this.
The golang Firestore sdk has a constant for the ServerTimestamp value : . https://godoc.org/cloud.google.com/go/firestore#pkg-constants.
And allows setting it in a struct as :
type TimeObject struct {
TS time.Time `firestore:"ts, serverTimestamp"`
}
This seems to be missing in the database
SDK. I guess the serverTimestamp
value is a sugar on top, but it would be nice to have the constant available in the database package as well.
Relevant Code:
type TimeObject struct {
TS time.Time `json:"ts"`
}
data := TimeObject{
TS: firebase.db.ServerTimestamp
}
_, err := firebase.db.NewRef("someref").Push(context.Background(), data)