# TransactionOptions

- [JSON representation](https://docs.cloud.google.com/datastore/docs/reference/data/rest/v1/TransactionOptions#SCHEMA_REPRESENTATION)
- [ReadWrite](https://docs.cloud.google.com/datastore/docs/reference/data/rest/v1/TransactionOptions#ReadWrite)
  - [JSON representation](https://docs.cloud.google.com/datastore/docs/reference/data/rest/v1/TransactionOptions#ReadWrite.SCHEMA_REPRESENTATION)
- [ReadOnly](https://docs.cloud.google.com/datastore/docs/reference/data/rest/v1/TransactionOptions#ReadOnly)
  - [JSON representation](https://docs.cloud.google.com/datastore/docs/reference/data/rest/v1/TransactionOptions#ReadOnly.SCHEMA_REPRESENTATION)

Options for beginning a new transaction.

Transactions can be created explicitly with calls to `https://docs.cloud.google.com/datastore/docs/reference/data/rest/v1/projects/beginTransaction#google.datastore.v1.Datastore.BeginTransaction` or implicitly by setting `https://docs.cloud.google.com/datastore/docs/reference/data/rest/v1/ReadOptions#FIELDS.new_transaction` in read requests.

| JSON representation |
|---|
| ``` { // Union field `mode` can be only one of the following: "readWrite": { object (`https://docs.cloud.google.com/datastore/docs/reference/data/rest/v1/TransactionOptions#ReadWrite`) }, "readOnly": { object (`https://docs.cloud.google.com/datastore/docs/reference/data/rest/v1/TransactionOptions#ReadOnly`) } // End of list of possible types for union field `mode`. } ``` |

| Fields ||
|---|---|
| Union field `mode`. The `mode` of the transaction, indicating whether write operations are supported. `mode` can be only one of the following: ||
| `readWrite` | ``object (`https://docs.cloud.google.com/datastore/docs/reference/data/rest/v1/TransactionOptions#ReadWrite`)`` The transaction should allow both reads and writes. |
| `readOnly` | ``object (`https://docs.cloud.google.com/datastore/docs/reference/data/rest/v1/TransactionOptions#ReadOnly`)`` The transaction should only allow reads. |

## ReadWrite

Options specific to read / write transactions.

| JSON representation |
|---|
| ``` { "previousTransaction": string } ``` |

| Fields ||
|---|---|
| `previousTransaction` | `string (https://developers.google.com/discovery/v1/type-format format)` The transaction identifier of the transaction being retried. A base64-encoded string. |

## ReadOnly

Options specific to read-only transactions.

| JSON representation |
|---|
| ``` { "readTime": string } ``` |

| Fields ||
|---|---|
| `readTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Reads entities at the given time. This must be a microsecond precision timestamp within the past one hour, or if Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the past 7 days. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |