googleapis / googleapis/google-cloud-go

firestore: Add function to convert firestore protobuf document to a struct

Open
#1,438 31 comments 19 reactions 1 assignee Assigned to @bhshkh View on GitHub
api: firestore type: feature request
Dominant language
Go
Stars
4.5k
Forks
1.6k
Avg merge
1d 13h
Merged PRs (30d)
109

Description

Cloud Functions supports Firestore triggers and when a document is updated an event is send to the function with this format:

``` go
pb "google.golang.org/genproto/googleapis/firestore/v1"

// FirestoreEvent is the payload of a Firestore event.
type FirestoreEvent struct {
OldValue pb.Document `json:"oldValue"`
Value pb.Document `json:"value"`
UpdateMask struct {
FieldPaths []string `json:"fieldPaths"`
} `json:"updateMask"`
}
```
There is currently no way to convert `pb.Document` to a normal Go struct. [setFromProtoValue](https://github.com/googleapis/google-cloud-go/blob/61166ef305533a6c5b0b3275df2cb544d678339a/firestore/from_value.go#L27) could be exported to make it possible or a new helper function based on this [DataTo](https://github.com/googleapis/google-cloud-go/blob/27b5416a80e6a65ee9eebda55f06def51b9b7b88/firestore/document.go#L115) line.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.