-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change before and after data should not be undefined for onUpdate #659
Comments
I found a few problems with this issue:
|
They are undefined for onWrite events when the data doesn't exist in either
the before or the after.
…On Sat, Apr 11, 2020, 4:02 PM Google Open Source Bot < ***@***.***> wrote:
I found a few problems with this issue:
- I couldn't figure out how to label this issue, so I've labeled it
for a human to triage. Hang tight.
- This issue does not seem to follow the issue template. Make sure you
provide all the required information.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#659 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAAH7SW5UPO6KUI3OG3P7LRMDZJ3ANCNFSM4MGFVGJQ>
.
|
@mbleigh i know about the restrictions for |
@mbleigh the same is true for |
If anyone needs to augment import {firestore} from 'firebase-functions';
import {Change, CloudFunction, EventContext} from 'firebase-functions';
import * as firebase from 'firebase-admin';
declare module 'firebase-functions/lib/providers/firestore' {
export type QueryDocumentSnapshot = firebase.firestore.QueryDocumentSnapshot;
interface DocumentBuilder {
/** Respond only to document updates. */
onUpdate(handler: (change: Change<QueryDocumentSnapshot>, context: EventContext) => PromiseLike<any> | any): CloudFunction<Change<QueryDocumentSnapshot>>;
/** Respond only to document creations. */
onCreate(handler: (snapshot: QueryDocumentSnapshot, context: EventContext) => PromiseLike<any> | any): CloudFunction<QueryDocumentSnapshot>;
/** Respond only to document deletions. */
onDelete(handler: (snapshot: QueryDocumentSnapshot, context: EventContext) => PromiseLike<any> | any): CloudFunction<QueryDocumentSnapshot>;
}
} I'd be happy to add this to a PR. |
Hey @sk- this is a great suggestion! When we first started supporting Firestore, QueryDocumentSnapshot was not introduced. If you can make the PR that would be very appreciated, I'd be happy to review. |
The arguments of Firestore triggers `onCreate`, `onUpdate` and `onDelete` cannot have an undefined data by definition, so we changed the arguments of those handlers to reflect that by using DocumentQuerySnapshot. fixes firebase#659
@laurenzlong great, I just sent #670 |
The change argument of the handler for
onUpdate
should probably beChange<QueryDocumentSnapshot>
instead ofChange<DocumentSnapshot>
, so thatchange.after.data()
andchange.before.data()
return a non undefined object.See https://github.com/firebase/firebase-functions/blob/master/src/providers/firestore.ts#L205-L212
If that's not the case, please clarify when either of those can be actually
undefined
.[REQUIRED] Version info
firebase-functions: 3.6.0
[REQUIRED] Expected behavior
change.before.data()
andchange.after.data()
should have a type ofDocumentData
[REQUIRED] Actual behavior
change.before.data()
andchange.after.data()
have a type ofDocumentData | undefined
The text was updated successfully, but these errors were encountered: