1amageek / pring.ts

Cloud Firestore model framework for TypeScript - Google
https://firebase.google.com/docs/firestore/
MIT License
108 stars 7 forks source link

support DeltaDocumentSnapshot #18

Closed starhoshi closed 6 years ago

starhoshi commented 6 years ago

DeltaDocumentSnapshot is used on Cloud Functions.

functions.firestore.document(`${DocumentPath.Order}/{orderID}`).onUpdate(async event => {
    // event.data is DeltaDocumentSnapshot
})

DeltaDocumentSnapshot

export interface DeltaDocumentSnapshot {
    exists: Boolean;
    ref: any;
    id: string;
    createTime: string;
    updateTime: string;
    readTime: string;
    previous: any;
    data: () => any;
    get: (key: string) => any;
}

DocumentSnapshot

  export class DocumentSnapshot {
    readonly exists: boolean;
    readonly ref: DocumentReference;
    readonly id: string;
    readonly createTime?: string;
    readonly updateTime?: string;
    readonly readTime: string;
    data(): DocumentData | undefined;
    get(fieldPath: string|FieldPath): any;
  }

Diff is the only previous. init method is compatible.