@InternalExtensionOnly public interface Firestore extends com.google.cloud.Service<FirestoreOptions>, AutoCloseable
Modifier and Type | Method and Description |
---|---|
WriteBatch |
batch()
Gets a Firestore
WriteBatch instance that can be used to combine multiple writes. |
BulkWriter |
bulkWriter()
Creates a
BulkWriter instance, used for performing multiple writes in parallel. |
BulkWriter |
bulkWriter(BulkWriterOptions options)
Creates a
BulkWriter instance, used for performing multiple writes in parallel. |
FirestoreBundle.Builder |
bundleBuilder()
Returns a FirestoreBundle.Builder
FirestoreBundle.Builder instance using an
automatically generated bundle ID. |
FirestoreBundle.Builder |
bundleBuilder(String bundleId)
Returns a FirestoreBundle.Builder
FirestoreBundle.Builder instance for the given bundle
ID. |
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. |
CollectionGroup |
collectionGroup(String collectionId)
Creates and returns a new
CollectionGroup 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.
|
void |
getAll(DocumentReference[] documentReferences,
FieldMask fieldMask,
com.google.api.gax.rpc.ApiStreamObserver<DocumentSnapshot> responseObserver)
Retrieves multiple documents from Firestore while optionally applying a field mask to reduce
the amount of data transmitted.
|
Iterable<CollectionReference> |
listCollections()
Fetches the root collections that are associated with this Firestore database.
|
com.google.api.core.ApiFuture<Void> |
recursiveDelete(CollectionReference reference)
Recursively deletes all documents and subcollections at and under the specified level.
|
com.google.api.core.ApiFuture<Void> |
recursiveDelete(CollectionReference reference,
BulkWriter bulkWriter)
Recursively deletes all documents and subcollections at and under the specified level.
|
com.google.api.core.ApiFuture<Void> |
recursiveDelete(DocumentReference reference)
Recursively deletes all documents and subcollections at and under the specified level.
|
com.google.api.core.ApiFuture<Void> |
recursiveDelete(DocumentReference reference,
BulkWriter bulkWriter)
Recursively deletes all documents and subcollections at and under the specified level.
|
<T> com.google.api.core.ApiFuture<T> |
runAsyncTransaction(Transaction.AsyncFunction<T> updateFunction)
Executes the given updateFunction and then attempts to commit the changes applied within the
transaction.
|
<T> com.google.api.core.ApiFuture<T> |
runAsyncTransaction(Transaction.AsyncFunction<T> updateFunction,
TransactionOptions transactionOptions)
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)
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.
|
void |
shutdown()
Initiates an orderly shutdown in which previously submitted work is finished, but no new work
will be accepted.
|
void |
shutdownNow()
Attempts to stop all actively executing work and halts the processing of waiting work.
|
@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.CollectionGroup collectionGroup(@Nonnull String collectionId)
CollectionGroup
that includes all documents in the database
that are contained in a collection or subcollection with the given @code{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 <T> com.google.api.core.ApiFuture<T> runAsyncTransaction(@Nonnull Transaction.AsyncFunction<T> updateFunction)
updateFunction
- The function to execute within the transaction context.@Nonnull <T> com.google.api.core.ApiFuture<T> runAsyncTransaction(@Nonnull Transaction.AsyncFunction<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.void getAll(@Nonnull DocumentReference[] documentReferences, @Nullable FieldMask fieldMask, com.google.api.gax.rpc.ApiStreamObserver<DocumentSnapshot> responseObserver)
documentReferences
- Array with Document References to fetch.fieldMask
- If not null, specifies the subset of fields to return.responseObserver
- The observer to be notified when DocumentSnapshot
details
arrive.@Nonnull WriteBatch batch()
WriteBatch
instance that can be used to combine multiple writes.@BetaApi @Nonnull BulkWriter bulkWriter()
BulkWriter
instance, used for performing multiple writes in parallel.
Gradually ramps up writes as specified by the 500/50/5 rule.@BetaApi @Nonnull BulkWriter bulkWriter(BulkWriterOptions options)
BulkWriter
instance, used for performing multiple writes in parallel.
Gradually ramps up writes as specified by the 500/50/5 rule unless otherwise configured by a
BulkWriterOptions object.options
- An options object to configure BulkWriter.@BetaApi @Nonnull com.google.api.core.ApiFuture<Void> recursiveDelete(CollectionReference reference)
If any delete fails, the ApiFuture contains an error with an error message containing the number of failed deletes and the stack trace of the last failed delete. The provided reference is deleted regardless of whether all deletes succeeded.
recursiveDelete() uses a BulkWriter
instance with default settings to perform the
deletes. To customize throttling rates or add success/error callbacks, pass in a custom
BulkWriter instance.
reference
- The reference of the collection to delete.@BetaApi @Nonnull com.google.api.core.ApiFuture<Void> recursiveDelete(CollectionReference reference, BulkWriter bulkWriter)
If any delete fails, the ApiFuture contains an error with an error message containing the number of failed deletes and the stack trace of the last failed delete. The provided reference is deleted regardless of whether all deletes succeeded.
recursiveDelete() uses a BulkWriter
instance with default settings to perform the
deletes. To customize throttling rates or add success/error callbacks, pass in a custom
BulkWriter instance.
reference
- The reference of the collection to delete.bulkWriter
- A custom BulkWriter instance used to perform the deletes.@BetaApi @Nonnull com.google.api.core.ApiFuture<Void> recursiveDelete(DocumentReference reference)
If any delete fails, the ApiFuture contains an error with an error message containing the number of failed deletes and the stack trace of the last failed delete. The provided reference is deleted regardless of whether all deletes succeeded.
recursiveDelete() uses a BulkWriter
instance with default settings to perform the
deletes. To customize throttling rates or add success/error callbacks, pass in a custom
BulkWriter instance.
reference
- The reference of the document to delete.@BetaApi @Nonnull com.google.api.core.ApiFuture<Void> recursiveDelete(DocumentReference reference, BulkWriter bulkWriter)
If any delete fails, the ApiFuture contains an error with an error message containing the number of failed deletes and the stack trace of the last failed delete. The provided reference is deleted regardless of whether all deletes succeeded.
recursiveDelete() uses a BulkWriter
instance with default settings to perform the
deletes. To customize throttling rates or add success/error callbacks, pass in a custom
BulkWriter instance.
reference
- The reference of the document to delete.bulkWriter
- A custom BulkWriter instance used to perform the deletes.@Nonnull FirestoreBundle.Builder bundleBuilder()
FirestoreBundle.Builder
instance using an
automatically generated bundle ID. When loaded on clients, client SDKs use the bundle ID and
the timestamp associated with the built bundle to tell if it has been loaded already.@Nonnull FirestoreBundle.Builder bundleBuilder(@Nonnull String bundleId)
FirestoreBundle.Builder
instance for the given bundle
ID.bundleId
- The ID of the bundle. When loaded on clients, client SDKs use this id and the
timestamp associated with the built bundle to tell if it has been loaded already.void close() throws Exception
close
in interface AutoCloseable
Exception
void shutdown()
void shutdownNow()
Copyright © 2023 Google LLC. All rights reserved.