public class CollectionReference extends Query
Subclassing Note: Firestore classes are not meant to be subclassed except for use in test mocks. Subclassing is not supported in production code and new SDK releases may break code that does so.
Query.Direction
Modifier and Type | Method and Description |
---|---|
com.google.api.core.ApiFuture<DocumentReference> |
add(Map<String,Object> fields)
Adds a new document to this collection with the specified data, assigning it a document ID
automatically.
|
com.google.api.core.ApiFuture<DocumentReference> |
add(Object pojo)
Adds a new document to this collection with the specified POJO as contents, assigning it a
document ID automatically.
|
DocumentReference |
document()
Returns a DocumentReference pointing to a new document with an auto-generated ID within this
collection.
|
DocumentReference |
document(String childPath)
Gets a DocumentReference instance that refers to the document that is a child of this
Collection.
|
String |
getId()
The id of a collection refers to the last component of path pointing to a collection, e.g.
|
DocumentReference |
getParent()
Returns a DocumentReference to the containing Document if this is a subcollection, else null.
|
String |
getPath()
A string representing the path of the referenced collection (relative to the root of the
database).
|
Iterable<DocumentReference> |
listDocuments()
Retrieves the list of documents in this collection.
|
addSnapshotListener, addSnapshotListener, endAt, endAt, endBefore, endBefore, equals, get, getFirestore, hashCode, limit, offset, orderBy, orderBy, orderBy, orderBy, select, select, startAfter, startAfter, startAt, startAt, stream, whereArrayContains, whereArrayContains, whereEqualTo, whereEqualTo, whereGreaterThan, whereGreaterThan, whereGreaterThanOrEqualTo, whereGreaterThanOrEqualTo, whereLessThan, whereLessThan, whereLessThanOrEqualTo, whereLessThanOrEqualTo
@Nonnull public String getId()
@Nullable public DocumentReference getParent()
@Nonnull public String getPath()
@Nonnull public DocumentReference document()
@Nonnull public DocumentReference document(@Nonnull String childPath)
childPath
- A relative and slash-separated path to a document.@Nonnull public Iterable<DocumentReference> listDocuments()
The document references returned may include references to "missing documents", i.e. document locations that have no document present but which contain subcollections with documents. Attempting to read such a document reference (e.g. via `get()` or `onSnapshot()`) will return a `DocumentSnapshot` whose `exists()` method returns false.
@Nonnull public com.google.api.core.ApiFuture<DocumentReference> add(@Nonnull Map<String,Object> fields)
fields
- A Map containing the data for the new document.document()
public com.google.api.core.ApiFuture<DocumentReference> add(Object pojo)
pojo
- The POJO that will be used to populate the contents of the documentdocument()
Copyright © 2019 Google LLC. All rights reserved.