Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-andersen committed Sep 25, 2023
1 parent 9cada8f commit 2ee882e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 21 deletions.
10 changes: 8 additions & 2 deletions dev/src/collection-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,16 @@ export class CollectionGroup<
* converter.
*/
withConverter(converter: null): CollectionGroup;
withConverter<NewAppModelType, NewDbModelType extends firestore.DocumentData>(
withConverter<
NewAppModelType,
NewDbModelType extends firestore.DocumentData = firestore.DocumentData
>(
converter: firestore.FirestoreDataConverter<NewAppModelType, NewDbModelType>
): CollectionGroup<NewAppModelType, NewDbModelType>;
withConverter<NewAppModelType, NewDbModelType extends firestore.DocumentData>(
withConverter<
NewAppModelType,
NewDbModelType extends firestore.DocumentData = firestore.DocumentData
>(
converter: firestore.FirestoreDataConverter<
NewAppModelType,
NewDbModelType
Expand Down
7 changes: 4 additions & 3 deletions dev/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1286,11 +1286,12 @@ export class Firestore implements firestore.Firestore {
* });
* ```
*/
getAll(
getAll<AppModelType, DbModelType extends firestore.DocumentData>(
...documentRefsOrReadOptions: Array<
firestore.DocumentReference | firestore.ReadOptions
| firestore.DocumentReference<AppModelType, DbModelType>
| firestore.ReadOptions
>
): Promise<Array<DocumentSnapshot>> {
): Promise<Array<DocumentSnapshot<AppModelType, DbModelType>>> {
validateMinNumberOfArguments(
'Firestore.getAll',
documentRefsOrReadOptions,
Expand Down
42 changes: 29 additions & 13 deletions dev/src/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,7 @@ export class DocumentReference<
* ```
*/
get(): Promise<DocumentSnapshot<AppModelType, DbModelType>> {
return this._firestore
.getAll(this as unknown as DocumentReference)
.then(
([result]) =>
result as unknown as DocumentSnapshot<AppModelType, DbModelType>
);
return this._firestore.getAll(this).then(([result]) => result);
}

/**
Expand Down Expand Up @@ -621,7 +616,10 @@ export class DocumentReference<
}

withConverter(converter: null): DocumentReference;
withConverter<NewAppModelType, NewDbModelType extends firestore.DocumentData>(
withConverter<
NewAppModelType,
NewDbModelType extends firestore.DocumentData = firestore.DocumentData
>(
converter: firestore.FirestoreDataConverter<NewAppModelType, NewDbModelType>
): DocumentReference<NewAppModelType, NewDbModelType>;
/**
Expand Down Expand Up @@ -675,7 +673,10 @@ export class DocumentReference<
* from Firestore. Passing in `null` removes the current converter.
* @return A DocumentReference that uses the provided converter.
*/
withConverter<NewAppModelType, NewDbModelType extends firestore.DocumentData>(
withConverter<
NewAppModelType,
NewDbModelType extends firestore.DocumentData = firestore.DocumentData
>(
converter: firestore.FirestoreDataConverter<
NewAppModelType,
NewDbModelType
Expand Down Expand Up @@ -1330,7 +1331,10 @@ export class QueryOptions<
);
}

withConverter<NewAppModelType, NewDbModelType extends firestore.DocumentData>(
withConverter<
NewAppModelType,
NewDbModelType extends firestore.DocumentData = firestore.DocumentData
>(
converter: firestore.FirestoreDataConverter<NewAppModelType, NewDbModelType>
): QueryOptions<NewAppModelType, NewDbModelType> {
return new QueryOptions<NewAppModelType, NewDbModelType>(
Expand Down Expand Up @@ -2766,7 +2770,10 @@ export class Query<
}

withConverter(converter: null): Query;
withConverter<NewAppModelType, NewDbModelType extends firestore.DocumentData>(
withConverter<
NewAppModelType,
NewDbModelType extends firestore.DocumentData = firestore.DocumentData
>(
converter: firestore.FirestoreDataConverter<NewAppModelType, NewDbModelType>
): Query<NewAppModelType, NewDbModelType>;
/**
Expand Down Expand Up @@ -2819,7 +2826,10 @@ export class Query<
* from Firestore. Passing in `null` removes the current converter.
* @return A Query that uses the provided converter.
*/
withConverter<NewAppModelType, NewDbModelType extends firestore.DocumentData>(
withConverter<
NewAppModelType,
NewDbModelType extends firestore.DocumentData = firestore.DocumentData
>(
converter: firestore.FirestoreDataConverter<
NewAppModelType,
NewDbModelType
Expand Down Expand Up @@ -3095,7 +3105,10 @@ export class CollectionReference<
}

withConverter(converter: null): CollectionReference;
withConverter<NewAppModelType, NewDbModelType extends firestore.DocumentData>(
withConverter<
NewAppModelType,
NewDbModelType extends firestore.DocumentData = firestore.DocumentData
>(
converter: firestore.FirestoreDataConverter<NewAppModelType, NewDbModelType>
): CollectionReference<NewAppModelType, NewDbModelType>;
/**
Expand Down Expand Up @@ -3149,7 +3162,10 @@ export class CollectionReference<
* from Firestore. Passing in `null` removes the current converter.
* @return A CollectionReference that uses the provided converter.
*/
withConverter<NewAppModelType, NewDbModelType extends firestore.DocumentData>(
withConverter<
NewAppModelType,
NewDbModelType extends firestore.DocumentData = firestore.DocumentData
>(
converter: firestore.FirestoreDataConverter<
NewAppModelType,
NewDbModelType
Expand Down
8 changes: 5 additions & 3 deletions types/firestore.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,11 @@ declare namespace FirebaseFirestore {
* @return A Promise that resolves with an array of resulting document
* snapshots.
*/
getAll(
...documentRefsOrReadOptions: Array<DocumentReference | ReadOptions>
): Promise<Array<DocumentSnapshot>>;
getAll<AppModelType, DbModelType extends DocumentData>(
...documentRefsOrReadOptions: Array<
DocumentReference<AppModelType, DbModelType> | ReadOptions
>
): Promise<Array<DocumentSnapshot<AppModelType, DbModelType>>>;

/**
* Recursively deletes all documents and subcollections at and under the
Expand Down

0 comments on commit 2ee882e

Please sign in to comment.