Firestore

public final class: Firestore
extends Object
java.lang.Object
   ↳ com.google.firebase.firestore.Firestore

Class Overview

Represents a Firestore Database and is the entry point for all Firestore operations

Summary

Nested Classes
enum Firestore.ListenState An enumeration of states a DocumentListen or QueryListen can be in. 
class Firestore.Options An options object used to configure Firestore. 
Public Methods
Collection collection(String name)
Gets a Collection referring to the collection with the specified name.
DocumentReference document(String collectionName, String documentId)
Gets a DocumentReference referring to the document with the specified documentID in the collection.
static Firestore fromOptions(Firestore.Options options)
Creates and returns a Firestore object using the specified options.
static Firestore fromProjectId(String projectId)
Creates and returns a Firestore object for the specified projectID, using the default FirebaseApp instance for authentication.
<TResult> Task<TResult> transaction(Function<TResult> updateFunction)
Executes the given updateFunction and then attempts to commit the changes applied within the transaction.
Inherited Methods
From class java.lang.Object

Public Methods

public Collection collection (String name)

Gets a Collection referring to the collection with the specified name.

Parameters
name String: The name of the collection to get a Collection for.
Returns
Collection The Collection for the specified name.

public DocumentReference document (String collectionName, String documentId)

Gets a DocumentReference referring to the document with the specified documentID in the collection.

Parameters
collectionName String: The name of the collection in which to look for a document.
documentId String: the id of the document within the collection.
Returns
DocumentReference The DocumentReference for the specified documentID within the collection with name collectionName.

public static Firestore fromOptions (Firestore.Options options)

Creates and returns a Firestore object using the specified options.

Parameters
options Firestore.Options: Options used to configure this Firestore instance.
Returns
Firestore The created Firestore instance.

public static Firestore fromProjectId (String projectId)

Creates and returns a Firestore object for the specified projectID, using the default FirebaseApp instance for authentication.

Parameters
projectId String: The Google Cloud Project ID for your Firestore Database.
Returns
Firestore The created Firestore instance.

public Task<TResult> transaction (Function<TResult> updateFunction)

Executes the given updateFunction and then attempts to commit the changes applied within the transaction. If any document read within the transaction has changed, the updateFunction will be retried. If it fails to commit after 5 attempts, the transaction will fail.

Parameters
updateFunction Function: The function to execute within the transaction context.
Returns
Task<TResult> The task returned from the updateFunction.

Send feedback about...

Need help? Visit our support page.