# Cloud Firestore V1 Client - Class Target (2.2.0-RC1)

2.2.0-RC1 2.1.0 (latest) 2.0.2-RC1 1.55.0 1.54.4 1.53.1 1.52.0 1.51.0 1.50.0 1.48.1 1.47.3 1.46.0 1.45.2 1.44.1 1.43.3 1.40.0 1.39.0 1.38.0 1.37.7 1.36.1 1.35.0 1.34.0 1.33.0 1.32.0 1.31.0 1.30.0 1.28.0 1.27.3 Reference documentation and code samples for the Cloud Firestore V1 Client class Target.

A specification of a set of documents to listen to.

Generated from protobuf message `google.firestore.v1.Target`

## Namespace

Google \\ Cloud \\ Firestore \\ V1

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ query` | `https://docs.cloud.google.com/php/docs/reference/cloud-firestore/latest/V1.Target.QueryTarget` A target specified by a query. |
| `↳ documents` | `https://docs.cloud.google.com/php/docs/reference/cloud-firestore/latest/V1.Target.DocumentsTarget` A target specified by a set of document names. |
| `↳ resume_token` | `string` A resume token from a prior [TargetChange](https://docs.cloud.google.com/php/docs/reference/cloud-firestore/latest/V1.TargetChange) for an identical target. Using a resume token with a different target is unsupported and may fail. |
| `↳ read_time` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp` Start listening after a specific `read_time`. The client must know the state of matching documents at this time. |
| `↳ target_id` | `int` The target ID that identifies the target on the stream. Must be a positive number and non-zero. If `target_id` is 0 (or unspecified), the server will assign an ID for this target and return that in a `TargetChange::ADD` event. Once a target with `target_id=0` is added, all subsequent targets must also have `target_id=0`. If an `AddTarget` request with `target_id != 0` is sent to the server after a target with `target_id=0` is added, the server will immediately send a response with a `TargetChange::Remove` event. Note that if the client sends multiple `AddTarget` requests without an ID, the order of IDs returned in `TargetChange.target_ids` are undefined. Therefore, clients should provide a target ID instead of relying on the server to assign one. If `target_id` is non-zero, there must not be an existing active target on this stream with the same ID. |
| `↳ once` | `bool` If the target should be removed once it is current and consistent. |
| `↳ expected_count` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Int32Value` The number of documents that last matched the query at the resume token or read time. This value is only relevant when a `resume_type` is provided. This value being present and greater than zero signals that the client wants `ExistenceFilter.unchanged_names` to be included in the response. |

### getQuery

A target specified by a query.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-firestore/latest/V1.Target.QueryTarget|null` |   |

### hasQuery

### setQuery

A target specified by a query.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-firestore/latest/V1.Target.QueryTarget` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getDocuments

A target specified by a set of document names.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-firestore/latest/V1.Target.DocumentsTarget|null` |   |

### hasDocuments

### setDocuments

A target specified by a set of document names.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-firestore/latest/V1.Target.DocumentsTarget` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getResumeToken

A resume token from a prior
[TargetChange](https://docs.cloud.google.com/php/docs/reference/cloud-firestore/latest/V1.TargetChange) for an identical target.

Using a resume token with a different target is unsupported and may fail.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### hasResumeToken

### setResumeToken

A resume token from a prior
[TargetChange](https://docs.cloud.google.com/php/docs/reference/cloud-firestore/latest/V1.TargetChange) for an identical target.

Using a resume token with a different target is unsupported and may fail.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getReadTime

Start listening after a specific `read_time`.

The client must know the state of matching documents at this time.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp|null` |   |

### hasReadTime

### setReadTime

Start listening after a specific `read_time`.

The client must know the state of matching documents at this time.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getTargetId

The target ID that identifies the target on the stream. Must be a positive
number and non-zero.

If `target_id` is 0 (or unspecified), the server will assign an ID for this
target and return that in a `TargetChange::ADD` event. Once a target with
`target_id=0` is added, all subsequent targets must also have
`target_id=0`. If an `AddTarget` request with `target_id != 0` is
sent to the server after a target with `target_id=0` is added, the server
will immediately send a response with a `TargetChange::Remove` event.
Note that if the client sends multiple `AddTarget` requests
without an ID, the order of IDs returned in `TargetChange.target_ids` are
undefined. Therefore, clients should provide a target ID instead of relying
on the server to assign one.
If `target_id` is non-zero, there must not be an existing active target on
this stream with the same ID.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` |   |

### setTargetId

The target ID that identifies the target on the stream. Must be a positive
number and non-zero.

If `target_id` is 0 (or unspecified), the server will assign an ID for this
target and return that in a `TargetChange::ADD` event. Once a target with
`target_id=0` is added, all subsequent targets must also have
`target_id=0`. If an `AddTarget` request with `target_id != 0` is
sent to the server after a target with `target_id=0` is added, the server
will immediately send a response with a `TargetChange::Remove` event.
Note that if the client sends multiple `AddTarget` requests
without an ID, the order of IDs returned in `TargetChange.target_ids` are
undefined. Therefore, clients should provide a target ID instead of relying
on the server to assign one.
If `target_id` is non-zero, there must not be an existing active target on
this stream with the same ID.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getOnce

If the target should be removed once it is current and consistent.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### setOnce

If the target should be removed once it is current and consistent.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `bool` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getExpectedCount

The number of documents that last matched the query at the resume token or
read time.

This value is only relevant when a `resume_type` is provided. This value
being present and greater than zero signals that the client wants
`ExistenceFilter.unchanged_names` to be included in the response.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Int32Value|null` |   |

### hasExpectedCount

### clearExpectedCount

### getExpectedCountValue

Returns the unboxed value from `getExpectedCount()`

The number of documents that last matched the query at the resume token or
read time.
This value is only relevant when a `resume_type` is provided. This value
being present and greater than zero signals that the client wants
`ExistenceFilter.unchanged_names` to be included in the response.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int|null` |   |

### setExpectedCount

The number of documents that last matched the query at the resume token or
read time.

This value is only relevant when a `resume_type` is provided. This value
being present and greater than zero signals that the client wants
`ExistenceFilter.unchanged_names` to be included in the response.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Int32Value` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### setExpectedCountValue

Sets the field by wrapping a primitive type in a Google\\Protobuf\\Int32Value object.

The number of documents that last matched the query at the resume token or
read time.
This value is only relevant when a `resume_type` is provided. This value
being present and greater than zero signals that the client wants
`ExistenceFilter.unchanged_names` to be included in the response.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int|null` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getTargetType

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### getResumeType

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |