From cf24a7dcc87e6e9074fb004cadf3949e05a8a96f Mon Sep 17 00:00:00 2001 From: Chris Bianca Date: Wed, 28 Mar 2018 16:00:58 +0100 Subject: [PATCH] [types] Add TypeScript typings for firestore transactions --- lib/index.d.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/index.d.ts b/lib/index.d.ts index c04bef1b..b89da276 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -1152,7 +1152,7 @@ declare module "react-native-firebase" { disableNetwork(): Promise doc(documentPath: string): DocumentReference; enableNetwork(): Promise - + runTransaction(updateFunction: (transaction: Transaction) => Promise): Promise; /** NOT SUPPORTED YET */ // enablePersistence(): Promise; /** NOT SUPPORTED YET */ @@ -1350,6 +1350,19 @@ declare module "react-native-firebase" { } } + interface Transaction { + delete(docRef: DocumentReference): WriteBatch; + get(documentRef: DocumentReference): Promise; + set(documentRef: DocumentReference, data: Object, options?: Types.WriteOptions): Transaction + // multiple overrides for update() to allow strong-typed var_args + update(docRef: DocumentReference, obj: object): WriteBatch; + update(docRef: DocumentReference, key1: Types.UpdateKey, val1: any): WriteBatch; + update(docRef: DocumentReference, key1: Types.UpdateKey, val1: any, key2: Types.UpdateKey, val2: any): WriteBatch; + update(docRef: DocumentReference, key1: Types.UpdateKey, val1: any, key2: Types.UpdateKey, val2: any, key3: Types.UpdateKey, val3: any): WriteBatch; + update(docRef: DocumentReference, key1: Types.UpdateKey, val1: any, key2: Types.UpdateKey, val2: any, key3: Types.UpdateKey, val3: any, key4: Types.UpdateKey, val4: any): WriteBatch; + update(docRef: DocumentReference, key1: Types.UpdateKey, val1: any, key2: Types.UpdateKey, val2: any, key3: Types.UpdateKey, val3: any, key4: Types.UpdateKey, val4: any, key5: Types.UpdateKey, val5: any): WriteBatch; + } + interface WriteBatch { commit(): Promise; delete(docRef: DocumentReference): WriteBatch;