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. |
DocumentReference |
document(String path)
Gets a
DocumentReference that refers to the document at the specified path. |
ApiFuture<List<DocumentSnapshot>> |
getAll(DocumentReference... documentReferences)
Retrieves multiple documents from Firestore.
|
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> ApiFuture<T> |
runTransaction(Transaction.Function<T> updateFunction)
Executes the given updateFunction and then attempts to commit the changes applied within the
transaction.
|
<T> 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.@Nonnull <T> ApiFuture<T> runTransaction(@Nonnull Transaction.Function<T> updateFunction)
updateFunction
- The function to execute within the transaction context.@Nonnull <T> ApiFuture<T> runTransaction(@Nonnull Transaction.Function<T> updateFunction, @Nonnull TransactionOptions transactionOptions)
updateFunction
- The function to execute within the transaction context.@Nonnull ApiFuture<List<DocumentSnapshot>> getAll(@Nonnull DocumentReference... documentReferences)
documentReferences
- List of Document References to fetch.@Nonnull 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.