Skip to content

fix: onCreate, onUpdate and onDelete receive a DocumentQuerySnapshopt #670

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

Merged
merged 1 commit into from
Apr 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/providers/firestore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const service = 'firestore.googleapis.com';
export const defaultDatabase = '(default)';
let firestoreInstance: any;
export type DocumentSnapshot = firebase.firestore.DocumentSnapshot;
export type QueryDocumentSnapshot = firebase.firestore.QueryDocumentSnapshot;

/**
* Select the Firestore document to listen to for events.
Expand Down Expand Up @@ -204,30 +205,30 @@ export class DocumentBuilder {
/** Respond only to document updates. */
onUpdate(
handler: (
change: Change<DocumentSnapshot>,
change: Change<QueryDocumentSnapshot>,
context: EventContext
) => PromiseLike<any> | any
): CloudFunction<Change<DocumentSnapshot>> {
): CloudFunction<Change<QueryDocumentSnapshot>> {
return this.onOperation(handler, 'document.update', changeConstructor);
}

/** Respond only to document creations. */
onCreate(
handler: (
snapshot: DocumentSnapshot,
snapshot: QueryDocumentSnapshot,
context: EventContext
) => PromiseLike<any> | any
): CloudFunction<DocumentSnapshot> {
): CloudFunction<QueryDocumentSnapshot> {
return this.onOperation(handler, 'document.create', snapshotConstructor);
}

/** Respond only to document deletions. */
onDelete(
handler: (
snapshot: DocumentSnapshot,
snapshot: QueryDocumentSnapshot,
context: EventContext
) => PromiseLike<any> | any
): CloudFunction<DocumentSnapshot> {
): CloudFunction<QueryDocumentSnapshot> {
return this.onOperation(
handler,
'document.delete',
Expand Down