Firebase Functions 1.0:beta-v1差异文档未收录event.params.pushId与event.data.ref
event.params.pushId and event.data.ref Hey there, I totally get the frustration when you’re digging through official migration docs and can’t track down specific details on the APIs you rely on. Let’s break down exactly what happened to those two properties in the 1.0 release:
What Replaces event.params.pushId?
In the beta version, when you set up a Realtime Database trigger with a wildcard path like /items/{pushId}, you’d grab the auto-generated push ID via event.params.pushId.
In 1.0+, the original event object was split into two focused parameters: change (for data-related values) and context (for metadata like request context and path placeholders). Now, that push ID lives under the context object:
context.params.pushId
This pattern applies to all path wildcards, not just push IDs—any placeholder you define in your trigger path will be accessible via context.params.
What Replaces event.data.ref?
In beta, event.data was a single DataSnapshot representing the state that triggered the function, and event.data.ref gave you the direct Database Reference to that location.
In 1.0+, Realtime Database triggers use a change parameter that includes both before and after snapshots (to handle create, update, and delete events cleanly). To get the reference to the triggered location:
- For create/update events: Use
change.after.ref - For delete events: Use
change.before.ref
If you’re working with Firestore triggers instead, you’ll find the equivalent reference under context.resource.ref.
The official beta-to-1.0 diff doc focuses more on high-level structural shifts (like the split of event into change and context) rather than listing every single property migration, which is why these specific details might not be called out explicitly.
内容的提问来源于stack exchange,提问作者Isaak Osipovich Dunayevsky

