public interface Firestore extends Service<FirestoreOptions>, AutoCloseable
Modifier and Type | Method and Description |
---|---|
WriteBatch |
batch()
Gets a Firestore
WriteBatch instance that can be used to combine multiple writes. |
void |
close()
Closes the gRPC channels associated with this instance and frees up their resources.
|
CollectionReference |
collection(String path)
Gets a
CollectionReference that refers to the collection at the specified path. |
Query |
collectionGroup(String collectionId)
Creates and returns a new @link{Query} that includes all documents in the database that are
contained in a collection or subcollection with the given @code{collectionId}.
|
DocumentReference |
document(String path)
Gets a
DocumentReference that refers to the document at the specified path. |
com.google.api.core.ApiFuture<List<DocumentSnapshot>> |
getAll(DocumentReference... documentReferences)
Retrieves multiple documents from Firestore.
|
com.google.api.core.ApiFuture<List<DocumentSnapshot>> |
getAll(DocumentReference[] documentReferences,
FieldMask fieldMask)
Retrieves multiple documents from Firestore, while optionally applying a field mask to reduce
the amount of data transmitted.
|
Iterable<CollectionReference> |
getCollections()
Deprecated.
Use `listCollections()`.
|
Iterable<CollectionReference> |
listCollections()
Fetches the root collections that are associated with this Firestore database.
|
<T> com.google.api.core.ApiFuture<T> |
runTransaction(Transaction.Function<T> updateFunction)
Executes the given updateFunction and then attempts to commit the changes applied within the
transaction.
|
<T> com.google.api.core.ApiFuture<T> |
runTransaction(Transaction.Function<T> updateFunction,
TransactionOptions transactionOptions)
Executes the given updateFunction and then attempts to commit the changes applied within the
transaction.
|
getOptions
@Nonnull CollectionReference collection(@Nonnull String path)
CollectionReference
that refers to the collection at the specified path.path
- A slash-separated path to a collection.@Nonnull DocumentReference document(@Nonnull String path)
DocumentReference
that refers to the document at the specified path.path
- A slash-separated path to a document.@Nonnull Iterable<CollectionReference> listCollections()
FirestoreException
- if the Iterable could not be initialized.@Nonnull Iterable<CollectionReference> getCollections()
FirestoreException
- if the Iterable could not be initialized.Query collectionGroup(@Nonnull String collectionId)
collectionId
- Identifies the collections to query over. Every collection or subcollection
with this ID as the last segment of its path will be included. Cannot contain a slash.@Nonnull <T> com.google.api.core.ApiFuture<T> runTransaction(@Nonnull Transaction.Function<T> updateFunction)
updateFunction
- The function to execute within the transaction context.@Nonnull <T> com.google.api.core.ApiFuture<T> runTransaction(@Nonnull Transaction.Function<T> updateFunction, @Nonnull TransactionOptions transactionOptions)
updateFunction
- The function to execute within the transaction context.@Nonnull com.google.api.core.ApiFuture<List<DocumentSnapshot>> getAll(@Nonnull DocumentReference... documentReferences)
documentReferences
- List of Document References to fetch.@Nonnull com.google.api.core.ApiFuture<List<DocumentSnapshot>> getAll(@Nonnull DocumentReference[] documentReferences, @Nullable FieldMask fieldMask)
documentReferences
- Array with Document References to fetch.fieldMask
- If set, specifies the subset of fields to return.@Nonnull WriteBatch batch()
WriteBatch
instance that can be used to combine multiple writes.void close() throws Exception
close
in interface AutoCloseable
Exception
Copyright © 2019 Google LLC. All rights reserved.