[types] Add TypeScript typings for firestore transactions

This commit is contained in:
Chris Bianca 2018-03-28 16:00:58 +01:00
parent 7f7169bd08
commit cf24a7dcc8
1 changed files with 14 additions and 1 deletions

15
lib/index.d.ts vendored
View File

@ -1152,7 +1152,7 @@ declare module "react-native-firebase" {
disableNetwork(): Promise<void>
doc(documentPath: string): DocumentReference;
enableNetwork(): Promise<void>
runTransaction(updateFunction: (transaction: Transaction) => Promise<any>): Promise<any>;
/** NOT SUPPORTED YET */
// enablePersistence(): Promise<void>;
/** NOT SUPPORTED YET */
@ -1350,6 +1350,19 @@ declare module "react-native-firebase" {
}
}
interface Transaction {
delete(docRef: DocumentReference): WriteBatch;
get(documentRef: DocumentReference): Promise<DocumentSnapshot>;
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<void>;
delete(docRef: DocumentReference): WriteBatch;