[go: nahoru, domu]

Skip to content
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

Overload getAll function to allow array destructuring #515

Merged
merged 8 commits into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Revert to original getAll function signature
  • Loading branch information
cxam committed Jan 8, 2019
commit c9ea282950416d5bcc144480b625822e6585bb09
7 changes: 3 additions & 4 deletions dev/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,13 +703,12 @@ export class Firestore {
* console.log(`Second document: ${JSON.stringify(docs[1])}`);
* });
*/
getAll(...documentRefsOrReadOptions: [
DocumentReference, ...Array<DocumentReference|ReadOptions>
]): Promise<DocumentSnapshot[]> {
getAll(...documentRefsOrReadOptions: Array<DocumentReference|ReadOptions>):
cxam marked this conversation as resolved.
Show resolved Hide resolved
Promise<DocumentSnapshot[]> {
this._validator.minNumberOfArguments('Firestore.getAll', arguments, 1);

const {documents, fieldMask} =
parseGetAllArguments(this._validator, [...documentRefsOrReadOptions]);
parseGetAllArguments(this._validator, documentRefsOrReadOptions);
return this.getAll_(documents, fieldMask, requestTag());
}

Expand Down
7 changes: 3 additions & 4 deletions dev/src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,16 @@ export class Transaction {
* });
* });
*/
getAll(...documentRefsOrReadOptions: [
DocumentReference, ...Array<DocumentReference|ReadOptions>
]): Promise<DocumentSnapshot[]> {
getAll(...documentRefsOrReadOptions: Array<DocumentReference|ReadOptions>):
Promise<DocumentSnapshot[]> {
if (!this._writeBatch.isEmpty) {
throw new Error(READ_AFTER_WRITE_ERROR_MSG);
}

this._validator.minNumberOfArguments('Transaction.getAll', arguments, 1);

const {documents, fieldMask} =
parseGetAllArguments(this._validator, [...documentRefsOrReadOptions]);
parseGetAllArguments(this._validator, documentRefsOrReadOptions);

return this._firestore.getAll_(
documents, fieldMask, this._requestTag, this._transactionId);
Expand Down
12 changes: 4 additions & 8 deletions types/firestore.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,8 @@ declare namespace FirebaseFirestore {
* @return A Promise that resolves with an array of resulting document
* snapshots.
*/
getAll(
...documentRefsOrReadOptions: [
DocumentReference, ...Array<DocumentReference|ReadOptions>
]): Promise<DocumentSnapshot[]>;
getAll(...documentRefsOrReadOptions: Array<DocumentReference|ReadOptions>):
Promise<DocumentSnapshot[]>;

/**
* Fetches the root collections that are associated with this Firestore
Expand Down Expand Up @@ -266,10 +264,8 @@ declare namespace FirebaseFirestore {
* @return A Promise that resolves with an array of resulting document
* snapshots.
*/
getAll(
...documentRefsOrReadOptions: [
DocumentReference, ...Array<DocumentReference|ReadOptions>
]): Promise<DocumentSnapshot[]>;
getAll(...documentRefsOrReadOptions: Array<DocumentReference|ReadOptions>):
Promise<DocumentSnapshot[]>;

/**
* Create the document referred to by the provided `DocumentReference`.
Expand Down