public final class TransactionOptionsOptions specifying the behavior of Firestore Transactions.
A transaction in Firestore can be either read-write or read-only.
The default set of options is a read-write transaction with a maximum number of 5 attempts. This attempt count can be customized via the ReadWriteOptionsBuilder#setNumberOfAttempts(int) method. A new instance of a builder can be created by calling #createReadWriteOptionsBuilder().
A read-only transaction can be configured via the ReadOnlyOptionsBuilder class. A new instance can be created by calling #createReadOnlyOptionsBuilder(). See Also: com.google.firestore.v1.TransactionOptions
Static Methods
create()
public static TransactionOptions create()Create a default set of options suitable for most use cases. Transactions will be opened as ReadWrite transactions and attempted up to 5 times. See Also: #createReadWriteOptionsBuilder()
| Type | Description |
| TransactionOptions | The TransactionOptions object. |
create(int numberOfAttempts) (deprecated)
public static TransactionOptions create(int numberOfAttempts)Deprecated. as of 2.0.0, replaced by ReadWriteOptionsBuilder#setNumberOfAttempts(int)
Create a default set of options with a custom number of retry attempts. See Also: #createReadWriteOptionsBuilder()
| Name | Description |
| numberOfAttempts | intThe number of execution attempts. |
| Type | Description |
| TransactionOptions | The TransactionOptions object. |
create(Executor executor) (deprecated)
public static TransactionOptions create(Executor executor)Deprecated. as of 2.0.0, replaced by ReadWriteOptionsBuilder#setExecutor(Executor)
Create a default set of options with a custom executor. See Also: #createReadWriteOptionsBuilder()
| Name | Description |
| executor | ExecutorThe executor to run the user callback code on. |
| Type | Description |
| TransactionOptions | The TransactionOptions object. |
create(Executor executor, int numberOfAttempts) (deprecated)
public static TransactionOptions create(Executor executor, int numberOfAttempts)Deprecated. as of 2.0.0, replaced by ReadWriteOptionsBuilder#setExecutor(Executor) and ReadWriteOptionsBuilder#setNumberOfAttempts(int)
Create a default set of options with a custom executor and a custom number of retry attempts. See Also: #createReadWriteOptionsBuilder()
| Name | Description |
| executor | ExecutorThe executor to run the user callback code on. |
| numberOfAttempts | intThe number of execution attempts. |
| Type | Description |
| TransactionOptions | The TransactionOptions object. |
createReadOnlyOptionsBuilder()
public static TransactionOptions.ReadOnlyOptionsBuilder createReadOnlyOptionsBuilder()| Type | Description |
| TransactionOptions.ReadOnlyOptionsBuilder | a new Builder with default values applicable to configuring options for a read-only transaction. |
createReadWriteOptionsBuilder()
public static TransactionOptions.ReadWriteOptionsBuilder createReadWriteOptionsBuilder()| Type | Description |
| TransactionOptions.ReadWriteOptionsBuilder | a new Builder with default values applicable to configuring options for a read-write transaction. |
Methods
getExecutor()
public Executor getExecutor()| Type | Description |
| Executor | Executor to be used to run user callbacks on |
getNumberOfAttempts()
public int getNumberOfAttempts()Returns the maximum number of times a transaction will be attempted before resulting in an error.
| Type | Description |
| int | The max number of attempts to try and commit the transaction. |
getReadTime()
public Timestamp getReadTime()A Timestamp specifying the time documents are to be read at. If null, the server will
read documents at the most up to date available. If non-null, the specified Timestamp
may not be more than 60 seconds in the past (evaluated when the request is processed by the
server).
| Type | Description |
| Timestamp | The specific time to read documents at. A null value means reading the most up to date data. |
getType()
public TransactionOptions.TransactionOptionsType getType()A type flag indicating the type of transaction represented.
| Type | Description |
| TransactionOptions.TransactionOptionsType | The type of transaction this represents. Either read-only or read-write. |