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

Deprecate getCollections in favor of listCollections #3758

Merged
merged 1 commit into from
Oct 4, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ public ApiFuture<DocumentSnapshot> get() {
* @throws FirestoreException if the Iterable could not be initialized.
* @return An Iterable that can be used to fetch all subcollections.
*/
public Iterable<CollectionReference> getCollections() {
public Iterable<CollectionReference> listCollections() {
ListCollectionIdsRequest.Builder request = ListCollectionIdsRequest.newBuilder();
request.setParent(path.toString());
final ListCollectionIdsPagedResponse response;
Expand Down Expand Up @@ -397,6 +397,18 @@ public void remove() {
};
}

/**
* Fetches the subcollections that are direct children of this document.
*
* @deprecated Use `listCollections()`.
*
* @throws FirestoreException if the Iterable could not be initialized.
* @return An Iterable that can be used to fetch all subcollections.
*/
public Iterable<CollectionReference> getCollections() {
return listCollections();
}

/**
* Starts listening to the document referenced by this DocumentReference.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ public interface Firestore extends Service<FirestoreOptions>, AutoCloseable {
* @return An Iterable that can be used to fetch all collections.
*/
@Nonnull
Iterable<CollectionReference> listCollections();

/**
* Fetches the root collections that are associated with this Firestore database.
*
* @deprecated Use `listCollections()`.
*
* @throws FirestoreException if the Iterable could not be initialized.
* @return An Iterable that can be used to fetch all collections.
*/
@Nonnull
Iterable<CollectionReference> getCollections();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,15 @@ public DocumentReference document(@Nonnull String documentPath) {

@Nonnull
@Override
public Iterable<CollectionReference> getCollections() {
public Iterable<CollectionReference> listCollections() {
DocumentReference rootDocument = new DocumentReference(this, this.databasePath);
return rootDocument.getCollections();
return rootDocument.listCollections();
}

@Nonnull
@Override
public Iterable<CollectionReference> getCollections() {
return listCollections();
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ public void omitWriteResultForDocumentTransforms()
}

@Test
public void getCollections() throws Exception {
public void listCollections() throws Exception {
// We test with 21 collections since 20 collections are by default returned in a single paged
// response.
String[] collections =
Expand All @@ -568,7 +568,7 @@ public void getCollections() throws Exception {
}
batch.commit().get();

Iterable<CollectionReference> collectionRefs = randomDoc.getCollections();
Iterable<CollectionReference> collectionRefs = randomDoc.listCollections();

int count = 0;
for (CollectionReference collectionRef : collectionRefs) {
Expand Down