In my Go Google Cloud Background Function I want to access params from my Firestore event.
https://cloud.google.com/functions/docs/writing/background#functions_background_parameters-go
points out that two objects - ctx and Event are passed to the background function entrypoint.
Event should be able to work with json.Unmarshal() of specific event that will be received.
With that knowledge, https://cloud.google.com/functions/docs/calling/cloud-firestore documents the event structure as
{
"oldValue": { // Update and Delete operations only
A Document object containing a pre-operation document snapshot
},
"updateMask": { // Update operations only
A DocumentMask object that lists changed fields.
},
"value": {
// A Document object containing a post-operation document snapshot
}
}
but it also states that Wildcard matches are extracted from document paths and stored in event.params. You can define as many wildcards as you like to substitute explicit collection or document IDs.
so according to the above, I should probably add something like
Params map[string]string `json:"params"`
to my struct used for decoding the event. Unfortunately that does not work. Any hints on how to access these named params from firestore events in Golang background function would be very welcome.
Params map[string]interface{} `json:"params"`?