Skip to content

Adding getCollections() to Typescript typings. #62

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

Merged
merged 3 commits into from
Nov 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,8 @@ class Firestore extends commonGrpc.Service {
* Fetches the root collections that are associated with this Firestore
* database.
*
* @returns {Promise.<Array.<CollectionReference>>} A Promise that
* contains an array with CollectionReferences.
* @returns {Promise.<Array.<CollectionReference>>} A Promise that resolves
* with an array of CollectionReferences.
*
* @example
* firestore.getCollections().then(collections => {
Expand Down
4 changes: 2 additions & 2 deletions src/reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ class DocumentReference {
/**
* Fetches the subcollections that are direct children of this document.
*
* @returns {Promise.<Array.<CollectionReference>>} A Promise that
* contains an array with CollectionReferences.
* @returns {Promise.<Array.<CollectionReference>>} A Promise that resolves
* with an array of CollectionReferences.
*
* @example
* let documentRef = firestore.doc('col/doc');
Expand Down
4 changes: 4 additions & 0 deletions test/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ xdescribe('firestore.d.ts', function() {
firestore.getAll(docRef1, docRef2).then(
(docs: DocumentSnapshot[]) => {
});
firestore.getCollections().then((collections:CollectionReference[]) => {
});
const transactionResult: Promise<string> = firestore.runTransaction(
(updateFunction: Transaction) => {
return Promise.resolve("string")
Expand Down Expand Up @@ -119,6 +121,8 @@ xdescribe('firestore.d.ts', function() {
const parent: CollectionReference = docRef.parent;
const path: string = docRef.path;
const subcollection: CollectionReference = docRef.collection('coll');
docRef.getCollections().then((collections:CollectionReference[]) => {
});
docRef.get().then((snapshot: DocumentSnapshot) => {
});
docRef.create(documentData).then(
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"noStrictGenericChecks": true
},
"include": [
"src/**/*.js",
"src/**/*.ts",
"test/typescript.ts",
"types/firestore.d.ts"
Expand Down
15 changes: 15 additions & 0 deletions types/firestore.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ declare namespace FirebaseFirestore {
*/
getAll(...documentRef: DocumentReference[]): Promise<DocumentSnapshot[]>;

/**
* Fetches the root collections that are associated with this Firestore
* database.
*
* @returns A Promise that resolves with an array of CollectionReferences.
*/
getCollections() : Promise<CollectionReference[]>;

/**
* Executes the given updateFunction and commits the changes applied within
* the transaction.
Expand Down Expand Up @@ -400,6 +408,13 @@ declare namespace FirebaseFirestore {
*/
collection(collectionPath: string): CollectionReference;

/**
* Fetches the subcollections that are direct children of this document.
*
* @returns A Promise that resolves with an array of CollectionReferences.
*/
getCollections() : Promise<CollectionReference[]>;

/**
* Creates a document referred to by this `DocumentReference` with the
* provided object values. The write fails if the document already exists
Expand Down