Package google.firestore.v1beta1

Index

Firestore

The Cloud Firestore service.

This service exposes several types of comparable timestamps:

  • create_time - The time at which a document was created. Changes only when a document is deleted, then re-created. Increases in a strict monotonic fashion.
  • update_time - The time at which a document was last updated. Changes every time a document is modified. Does not change when a write results in no modifications. Increases in a strict monotonic fashion.
  • read_time - The time at which a particular state was observed. Used to denote a consistent snapshot of the database or the time at which a Document was observed to not exist.
  • commit_time - The time at which the writes in a transaction were committed. Any read with an equal or greater read_time is guaranteed to see the effects of the transaction.
BatchGetDocuments

rpc BatchGetDocuments(BatchGetDocumentsRequest) returns (BatchGetDocumentsResponse)

Gets multiple documents.

Documents returned by this method are not guaranteed to be returned in the same order that they were requested.

Authorization Scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/datastore
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

BeginTransaction

rpc BeginTransaction(BeginTransactionRequest) returns (BeginTransactionResponse)

Starts a new transaction.

Authorization Scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/datastore
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

Commit

rpc Commit(CommitRequest) returns (CommitResponse)

Commits a transaction, while optionally updating documents.

Authorization Scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/datastore
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

CreateDocument

rpc CreateDocument(CreateDocumentRequest) returns (Document)

Creates a new document.

Authorization Scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/datastore
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

DeleteDocument

rpc DeleteDocument(DeleteDocumentRequest) returns (Empty)

Deletes a document.

Authorization Scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/datastore
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

GetDocument

rpc GetDocument(GetDocumentRequest) returns (Document)

Gets a single document.

Authorization Scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/datastore
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

ListCollectionIds

rpc ListCollectionIds(ListCollectionIdsRequest) returns (ListCollectionIdsResponse)

Lists all the collection IDs underneath a document.

Authorization Scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/datastore
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

ListDocuments

rpc ListDocuments(ListDocumentsRequest) returns (ListDocumentsResponse)

Lists documents.

Authorization Scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/datastore
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

Listen

rpc Listen(ListenRequest) returns (ListenResponse)

Listens to changes.

Authorization Scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/datastore
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

Rollback

rpc Rollback(RollbackRequest) returns (Empty)

Rolls back a transaction.

Authorization Scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/datastore
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

RunQuery

rpc RunQuery(RunQueryRequest) returns (RunQueryResponse)

Runs a query.

Authorization Scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/datastore
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

UpdateDocument

rpc UpdateDocument(UpdateDocumentRequest) returns (Document)

Updates or inserts a document.

Authorization Scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/datastore
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

Write

rpc Write(WriteRequest) returns (WriteResponse)

Streams batches of document updates and deletes, in order.

Authorization Scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/datastore
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

ArrayValue

An array value.

Fields
values[]

Value

Values in the array.

BatchGetDocumentsRequest

The request for Firestore.BatchGetDocuments.

Fields
database

string

The database name. In the format: projects/{project_id}/databases/{database_id}.

documents[]

string

The names of the documents to retrieve. In the format: projects/{project_id}/databases/{database_id}/documents/{document_path}. The request will fail if any of the document is not a child resource of the given database. Duplicate names will be elided.

mask

DocumentMask

The fields to return. If not set, returns all fields.

If a document has a field that is not present in this mask, that field will not be returned in the response.

Union field consistency_selector. The consistency mode for this transaction. If not set, defaults to strong consistency. consistency_selector can be only one of the following:
transaction

bytes

Reads documents in a transaction.

new_transaction

TransactionOptions

Starts a new transaction and reads the documents. Defaults to a read-only transaction. The new transaction ID will be returned as the first response in the stream.

read_time

Timestamp

Reads documents as they were at the given time. This may not be older than 60 seconds.

BatchGetDocumentsResponse

The streamed response for Firestore.BatchGetDocuments.

Fields
transaction

bytes

The transaction that was started as part of this request. Will only be set in the first response, and only if BatchGetDocumentsRequest.new_transaction was set in the request.

read_time

Timestamp

The time at which the document was read. This may be monotically increasing, in this case the previous documents in the result stream are guaranteed not to have changed between their read_time and this one.

Union field result. A single result. This can be empty if the server is just returning a transaction. result can be only one of the following:
found

Document

A document that was requested.

missing

string

A document name that was requested but does not exist. In the format: projects/{project_id}/databases/{database_id}/documents/{document_path}.

BeginTransactionRequest

The request for Firestore.BeginTransaction.

Fields
database

string

The database name. In the format: projects/{project_id}/databases/{database_id}.

options

TransactionOptions

The options for the transaction. Defaults to a read-write transaction.

BeginTransactionResponse

The response for Firestore.BeginTransaction.

Fields
transaction

bytes

The transaction that was started.

CommitRequest

The request for Firestore.Commit.

Fields
database

string

The database name. In the format: projects/{project_id}/databases/{database_id}.

writes[]

Write

The writes to apply.

Always executed atomically and in order.

transaction

bytes

If set, applies all writes in this transaction, and commits it.

CommitResponse

The response for Firestore.Commit.

Fields
write_results[]

WriteResult

The result of applying the writes.

This i-th write result corresponds to the i-th write in the request.

commit_time

Timestamp

The time at which the commit occurred.

CreateDocumentRequest

The request for Firestore.CreateDocument.

Fields
parent

string

The parent resource. For example: projects/{project_id}/databases/{database_id}/documents or projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}

collection_id

string

The collection ID, relative to parent, to list. For example: chatrooms.

document_id

string

The client-assigned document ID to use for this document.

Optional. If not specified, an ID will be assigned by the service.

document

Document

The document to create. name must not be set.

mask

DocumentMask

The fields to return. If not set, returns all fields.

If the document has a field that is not present in this mask, that field will not be returned in the response.

Cursor

A position in a query result set.

Fields
values[]

Value

The values that represent a position, in the order they appear in the order by clause of a query.

Can contain fewer values than specified in the order by clause.

before

bool

If the position is just before or just after the given values, relative to the sort order defined by the query.

DeleteDocumentRequest

The request for Firestore.DeleteDocument.

Fields
name

string

The resource name of the Document to delete. In the format: projects/{project_id}/databases/{database_id}/documents/{document_path}.

current_document

Precondition

An optional precondition on the document. The request will fail if this is set and not met by the target document.

Document

A Firestore document.

Must not exceed 1 MiB - 4 bytes.

Fields
name

string

The resource name of the document, for example projects/{project_id}/databases/{database_id}/documents/{document_path}.

fields

map<string, Value>

The document's fields.

The map keys represent field names.

A simple field name contains only characters a to z, A to Z, 0 to 9, or _, and must not start with 0 to 9. For example, foo_bar_17.

Field names matching the regular expression __.*__ are reserved. Reserved field names are forbidden except in certain documented contexts. The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot be empty.

Field paths may be used in other contexts to refer to structured fields defined here. For map_value, the field path is represented by the simple or quoted field names of the containing fields, delimited by .. For example, the structured field "foo" : { map_value: { "x&y" : { string_value: "hello" }}} would be represented by the field path foo.x&y.

Within a field path, a quoted field name starts and ends with ` and may contain any character. Some characters, including `, must be escaped using a \. For example, `x&y` represents x&y and `bak\`tik` represents bak`tik.

create_time

Timestamp

Output only. The time at which the document was created.

This value increases monotonically when a document is deleted then recreated. It can also be compared to values from other documents and the read_time of a query.

update_time

Timestamp

Output only. The time at which the document was last changed.

This value is initially set to the create_time then increases monotonically with each change to the document. It can also be compared to values from other documents and the read_time of a query.

DocumentChange

A Document has changed.

May be the result of multiple writes, including deletes, that ultimately resulted in a new value for the Document.

Multiple DocumentChange messages may be returned for the same logical change, if multiple targets are affected.

Fields
document

Document

The new state of the Document.

If mask is set, contains only fields that were updated or added.

target_ids[]

int32

A set of target IDs of targets that match this document.

removed_target_ids[]

int32

A set of target IDs for targets that no longer match this document.

DocumentDelete

A Document has been deleted.

May be the result of multiple writes, including updates, the last of which deleted the Document.

Multiple DocumentDelete messages may be returned for the same logical delete, if multiple targets are affected.

Fields
document

string

The resource name of the Document that was deleted.

removed_target_ids[]

int32

A set of target IDs for targets that previously matched this entity.

read_time

Timestamp

The read timestamp at which the delete was observed.

Greater or equal to the commit_time of the delete.

DocumentMask

A set of field paths on a document. Used to restrict a get or update operation on a document to a subset of its fields. This is different from standard field masks, as this is always scoped to a Document, and takes in account the dynamic nature of Value.

Fields
field_paths[]

string

The list of field paths in the mask. See Document.fields for a field path syntax reference.

DocumentRemove

A Document has been removed from the view of the targets.

Sent if the document is no longer relevant to a target and is out of view. Can be sent instead of a DocumentDelete or a DocumentChange if the server can not send the new value of the document.

Multiple DocumentRemove messages may be returned for the same logical write or delete, if multiple targets are affected.

Fields
document

string

The resource name of the Document that has gone out of view.

removed_target_ids[]

int32

A set of target IDs for targets that previously matched this document.

read_time

Timestamp

The read timestamp at which the remove was observed.

Greater or equal to the commit_time of the change/delete/remove.

DocumentTransform

A transformation of a document.

Fields
document

string

The name of the document to transform.

field_transforms[]

FieldTransform

The list of transformations to apply to the fields of the document, in order. This must not be empty.

FieldTransform

A transformation of a field of the document.

Fields
field_path

string

The path of the field. See Document.fields for the field path syntax reference.

set_to_server_value

ServerValue

Sets the field to the given server value.

ServerValue

A value that is calculated by the server.

Enums
SERVER_VALUE_UNSPECIFIED Unspecified. This value must not be used.
REQUEST_TIME The time at which the server processed the request, with millisecond precision.

ExistenceFilter

A digest of all the documents that match a given target.

Fields
target_id

int32

The target ID to which this filter applies.

count

int32

The total count of documents that match target_id.

If different from the count of documents in the client that match, the client must manually determine which documents no longer match the target.

GetDocumentRequest

The request for Firestore.GetDocument.

Fields
name

string

The resource name of the Document to get. In the format: projects/{project_id}/databases/{database_id}/documents/{document_path}.

mask

DocumentMask

The fields to return. If not set, returns all fields.

If the document has a field that is not present in this mask, that field will not be returned in the response.

Union field consistency_selector. The consistency mode for this transaction. If not set, defaults to strong consistency. consistency_selector can be only one of the following:
transaction

bytes

Reads the document in a transaction.

read_time

Timestamp

Reads the version of the document at the given time. This may not be older than 60 seconds.

ListCollectionIdsRequest

The request for Firestore.ListCollectionIds.

Fields
parent

string

The parent document. In the format: projects/{project_id}/databases/{database_id}/documents/{document_path}. For example: projects/my-project/databases/my-database/documents/chatrooms/my-chatroom

page_size

int32

The maximum number of results to return.

page_token

string

A page token. Must be a value from ListCollectionIdsResponse.

ListCollectionIdsResponse

The response from Firestore.ListCollectionIds.

Fields
collection_ids[]

string

The collection ids.

next_page_token

string

A page token that may be used to continue the list.

ListDocumentsRequest

The request for Firestore.ListDocuments.

Fields
parent

string

The parent resource name. In the format: projects/{project_id}/databases/{database_id}/documents or projects/{project_id}/databases/{database_id}/documents/{document_path}. For example: projects/my-project/databases/my-database/documents or projects/my-project/databases/my-database/documents/chatrooms/my-chatroom

collection_id

string

The collection ID, relative to parent, to list. For example: chatrooms or messages.

page_size

int32

The maximum number of documents to return.

page_token

string

The next_page_token value returned from a previous List request, if any.

order_by

string

The order to sort results by. For example: priority desc, name.

mask

DocumentMask

The fields to return. If not set, returns all fields.

If a document has a field that is not present in this mask, that field will not be returned in the response.

show_missing

bool

If the list should show missing documents. A missing document is a document that does not exist but has sub-documents. These documents will be returned with a key but will not have fields, Document.create_time, or Document.update_time set.

Requests with show_missing may not specify where or order_by.

Union field consistency_selector. The consistency mode for this transaction. If not set, defaults to strong consistency. consistency_selector can be only one of the following:
transaction

bytes

Reads documents in a transaction.

read_time

Timestamp

Reads documents as they were at the given time. This may not be older than 60 seconds.

ListDocumentsResponse

The response for Firestore.ListDocuments.

Fields
documents[]

Document

The Documents found.

next_page_token

string

The next page token.

ListenRequest

A request for Firestore.Listen

Fields
database

string

The database name. In the format: projects/{project_id}/databases/{database_id}.

labels

map<string, string>

Labels associated with this target change.

Union field target_change. The supported target changes. target_change can be only one of the following:
add_target

Target

A target to add to this stream.

remove_target

int32

The ID of a target to remove from this stream.

ListenResponse

The response for Firestore.Listen.

Fields
Union field response_type. The supported responses. response_type can be only one of the following:
target_change

TargetChange

Targets have changed.

document_change

DocumentChange

A Document has changed.

document_delete

DocumentDelete

A Document has been deleted.

document_remove

DocumentRemove

A Document has been removed from a target (because it is no longer relevant to that target).

filter

ExistenceFilter

A filter to apply to the set of documents previously returned for the given target.

Returned when documents may have been removed from the given target, but the exact documents are unknown.

MapValue

A map value.

Fields
fields

map<string, Value>

The map's fields.

The map keys represent field names. Field names matching the regular expression __.*__ are reserved. Reserved field names are forbidden except in certain documented contexts. The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot be empty.

Precondition

A precondition on a document, used for conditional operations.

Fields
Union field condition_type. The type of precondition. condition_type can be only one of the following:
exists

bool

When set to true, the target document must exist. When set to false, the target document must not exist.

update_time

Timestamp

When set, the target document must exist and have been last updated at that time.

RollbackRequest

The request for Firestore.Rollback.

Fields
database

string

The database name. In the format: projects/{project_id}/databases/{database_id}.

transaction

bytes

The transaction to roll back.

RunQueryRequest

The request for Firestore.RunQuery.

Fields
parent

string

The parent resource name. In the format: projects/{project_id}/databases/{database_id}/documents or projects/{project_id}/databases/{database_id}/documents/{document_path}. For example: projects/my-project/databases/my-database/documents or projects/my-project/databases/my-database/documents/chatrooms/my-chatroom

structured_query

StructuredQuery

A structured query.

Union field consistency_selector. The consistency mode for this transaction. If not set, defaults to strong consistency. consistency_selector can be only one of the following:
transaction

bytes

Reads documents in a transaction.

new_transaction

TransactionOptions

Starts a new transaction and reads the documents. Defaults to a read-only transaction. The new transaction ID will be returned as the first response in the stream.

read_time

Timestamp

Reads documents as they were at the given time. This may not be older than 60 seconds.

RunQueryResponse

The response for Firestore.RunQuery.

Fields
transaction

bytes

The transaction that was started as part of this request. Can only be set in the first response, and only if RunQueryRequest.new_transaction was set in the request. If set, no other fields will be set in this response.

document

Document

A query result. Not set when reporting partial progress.

read_time

Timestamp

The time at which the document was read. This may be monotonically increasing; in this case, the previous documents in the result stream are guaranteed not to have changed between their read_time and this one.

If the query returns no results, a response with read_time and no document will be sent, and this represents the time at which the query was run.

skipped_results

int32

The number of results that have been skipped due to an offset between the last response and the current response.

StructuredQuery

A Firestore query.

Fields
select

Projection

The projection to return.

from[]

CollectionSelector

The collections to query.

where

Filter

The filter to apply.

order_by[]

Order

The order to apply to the query results.

Firestore guarantees a stable ordering through the following rules:

  • Any field required to appear in order_by, that is not already specified in order_by, is appended to the order in field name order by default.
  • If an order on __name__ is not specified, it is appended by default.

Fields are appended with the same sort direction as the last order specified, or 'ASCENDING' if no order was specified. For example:

  • SELECT * FROM Foo ORDER BY A becomes SELECT * FROM Foo ORDER BY A, __name__
  • SELECT * FROM Foo ORDER BY A DESC becomes SELECT * FROM Foo ORDER BY A DESC, __name__ DESC
  • SELECT * FROM Foo WHERE A > 1 becomes SELECT * FROM Foo WHERE A > 1 ORDER BY A, __name__

start_at

Cursor

A starting point for the query results.

end_at

Cursor

A end point for the query results.

offset

int32

The number of results to skip.

Applies before limit, but after all other constraints. Must be >= 0 if specified.

limit

Int32Value

The maximum number of results to return.

Applies after all other constraints. Must be >= 0 if specified.

CollectionSelector

A selection of a collection, such as messages as m1.

Fields
collection_id

string

The collection ID. When set, selects only collections with this ID.

all_descendants

bool

When false, selects only collections that are immediate children of the parent specified in the containing RunQueryRequest. When true, selects all descendant collections.

CompositeFilter

A filter that merges multiple other filters using the given operator.

Fields
op

Operator

The operator for combining multiple filters.

filters[]

Filter

The list of filters to combine. Must contain at least one filter.

Operator

A composite filter operator.

Enums
OPERATOR_UNSPECIFIED Unspecified. This value must not be used.
AND The results are required to satisfy each of the combined filters.

Direction

A sort direction.

Enums
DIRECTION_UNSPECIFIED Unspecified.
ASCENDING Ascending.
DESCENDING Descending.

FieldFilter

A filter on a specific field.

Fields
field

FieldReference

The field to filter by.

op

Operator

The operator to filter by.

value

Value

The value to compare to.

Operator

A field filter operator.

Enums
OPERATOR_UNSPECIFIED Unspecified. This value must not be used.
LESS_THAN Less than. Requires that the field come first in order_by.
LESS_THAN_OR_EQUAL Less than or equal. Requires that the field come first in order_by.
GREATER_THAN Greater than. Requires that the field come first in order_by.
GREATER_THAN_OR_EQUAL Greater than or equal. Requires that the field come first in order_by.
EQUAL Equal.
ARRAY_CONTAINS Contains. Requires that the field is an array.

FieldReference

A reference to a field, such as max(messages.time) as max_time.

Fields
field_path

string

Filter

A filter.

Fields
Union field filter_type. The type of filter. filter_type can be only one of the following:
composite_filter

CompositeFilter

A composite filter.

field_filter

FieldFilter

A filter on a document field.

unary_filter

UnaryFilter

A filter that takes exactly one argument.

Order

An order on a field.

Fields
field

FieldReference

The field to order by.

direction

Direction

The direction to order by. Defaults to ASCENDING.

Projection

The projection of document's fields to return.

Fields
fields[]

FieldReference

The fields to return.

If empty, all fields are returned. To only return the name of the document, use ['__name__'].

UnaryFilter

A filter with a single operand.

Fields
op

Operator

The unary operator to apply.

field

FieldReference

The field to which to apply the operator.

Operator

A unary operator.

Enums
OPERATOR_UNSPECIFIED Unspecified. This value must not be used.
IS_NAN Test if a field is equal to NaN.
IS_NULL Test if an exprestion evaluates to Null.

Target

A specification of a set of documents to listen to.

Fields
target_id

int32

A client provided target ID.

If not set, the server will assign an ID for the target.

Used for resuming a target without changing IDs. The IDs can either be client-assigned or be server-assigned in a previous stream. All targets with client provided IDs must be added before adding a target that needs a server-assigned id.

once

bool

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

Union field target_type. The type of target to listen to. target_type can be only one of the following:
query

QueryTarget

A target specified by a query.

documents

DocumentsTarget

A target specified by a set of document names.

Union field resume_type. When to start listening.

If not specified, all matching Documents are returned before any subsequent changes. resume_type can be only one of the following:

resume_token

bytes

A resume token from a prior TargetChange for an identical target.

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

read_time

Timestamp

Start listening after a specific read_time.

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

DocumentsTarget

A target specified by a set of documents names.

Fields
documents[]

string

The names of the documents to retrieve. In the format: projects/{project_id}/databases/{database_id}/documents/{document_path}. The request will fail if any of the document is not a child resource of the given database. Duplicate names will be elided.

QueryTarget

A target specified by a query.

Fields
parent

string

The parent resource name. In the format: projects/{project_id}/databases/{database_id}/documents or projects/{project_id}/databases/{database_id}/documents/{document_path}. For example: projects/my-project/databases/my-database/documents or projects/my-project/databases/my-database/documents/chatrooms/my-chatroom

structured_query

StructuredQuery

A structured query.

TargetChange

Targets being watched have changed.

Fields
target_change_type

TargetChangeType

The type of change that occurred.

target_ids[]

int32

The target IDs of targets that have changed.

If empty, the change applies to all targets.

For target_change_type=ADD, the order of the target IDs matches the order of the requests to add the targets. This allows clients to unambiguously associate server-assigned target IDs with added targets.

For other states, the order of the target IDs is not defined.

cause

Status

The error that resulted in this change, if applicable.

resume_token

bytes

A token that can be used to resume the stream for the given target_ids, or all targets if target_ids is empty.

Not set on every target change.

read_time

Timestamp

The consistent read_time for the given target_ids (omitted when the target_ids are not at a consistent snapshot).

The stream is guaranteed to send a read_time with target_ids empty whenever the entire stream reaches a new consistent snapshot. ADD, CURRENT, and RESET messages are guaranteed to (eventually) result in a new consistent snapshot (while NO_CHANGE and REMOVE messages are not).

For a given stream, read_time is guaranteed to be monotonically increasing.

TargetChangeType

The type of change.

Enums
NO_CHANGE No change has occurred. Used only to send an updated resume_token.
ADD The targets have been added.
REMOVE The targets have been removed.
CURRENT

The targets reflect all changes committed before the targets were added to the stream.

This will be sent after or with a read_time that is greater than or equal to the time at which the targets were added.

Listeners can wait for this change if read-after-write semantics are desired.

RESET

The targets have been reset, and a new initial state for the targets will be returned in subsequent changes.

After the initial state is complete, CURRENT will be returned even if the target was previously indicated to be CURRENT.

TransactionOptions

Options for creating a new transaction.

Fields
Union field mode. The mode of the transaction. mode can be only one of the following:
read_only

ReadOnly

The transaction can only be used for read operations.

read_write

ReadWrite

The transaction can be used for both read and write operations.

ReadOnly

Options for a transaction that can only be used to read documents.

Fields
read_time

Timestamp

Reads documents at the given time. This may not be older than 60 seconds.

ReadWrite

Options for a transaction that can be used to read and write documents.

Fields
retry_transaction

bytes

An optional transaction to retry.

UpdateDocumentRequest

The request for Firestore.UpdateDocument.

Fields
document

Document

The updated document. Creates the document if it does not already exist.

update_mask

DocumentMask

The fields to update. None of the field paths in the mask may contain a reserved name.

If the document exists on the server and has fields not referenced in the mask, they are left unchanged. Fields referenced in the mask, but not present in the input document, are deleted from the document on the server.

mask

DocumentMask

The fields to return. If not set, returns all fields.

If the document has a field that is not present in this mask, that field will not be returned in the response.

current_document

Precondition

An optional precondition on the document. The request will fail if this is set and not met by the target document.

Value

A message that can hold any of the supported value types.

Fields
Union field value_type. Must have a value set. value_type can be only one of the following:
null_value

NullValue

A null value.

boolean_value

bool

A boolean value.

integer_value

int64

An integer value.

double_value

double

A double value.

timestamp_value

Timestamp

A timestamp value.

Precise only to microseconds. When stored, any additional precision is rounded down.

string_value

string

A string value.

The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes. Only the first 1,500 bytes of the UTF-8 representation are considered by queries.

bytes_value

bytes

A bytes value.

Must not exceed 1 MiB - 89 bytes. Only the first 1,500 bytes are considered by queries.

reference_value

string

A reference to a document. For example: projects/{project_id}/databases/{database_id}/documents/{document_path}.

geo_point_value

LatLng

A geo point value representing a point on the surface of Earth.

array_value

ArrayValue

An array value.

Cannot directly contain another array value, though can contain an map which contains another array.

map_value

MapValue

A map value.

Write

A write on a document.

Fields
update_mask

DocumentMask

The fields to update in this write.

This field can be set only when the operation is update. If the mask is not set for an update and the document exists, any existing data will be overwritten. If the mask is set and the document on the server has fields not covered by the mask, they are left unchanged. Fields referenced in the mask, but not present in the input document, are deleted from the document on the server. The field paths in this mask must not contain a reserved field name.

current_document

Precondition

An optional precondition on the document.

The write will fail if this is set and not met by the target document.

Union field operation. The operation to execute. operation can be only one of the following:
update

Document

A document to write.

delete

string

A document name to delete. In the format: projects/{project_id}/databases/{database_id}/documents/{document_path}.

transform

DocumentTransform

Applies a tranformation to a document. At most one transform per document is allowed in a given request. An update cannot follow a transform on the same document in a given request.

WriteRequest

The request for Firestore.Write.

The first request creates a stream, or resumes an existing one from a token.

When creating a new stream, the server replies with a response containing only an ID and a token, to use in the next request.

When resuming a stream, the server first streams any responses later than the given token, then a response containing only an up-to-date token, to use in the next request.

Fields
database

string

The database name. In the format: projects/{project_id}/databases/{database_id}. This is only required in the first message.

stream_id

string

The ID of the write stream to resume. This may only be set in the first message. When left empty, a new write stream will be created.

writes[]

Write

The writes to apply.

Always executed atomically and in order. This must be empty on the first request. This may be empty on the last request. This must not be empty on all other requests.

stream_token

bytes

A stream token that was previously sent by the server.

The client should set this field to the token from the most recent WriteResponse it has received. This acknowledges that the client has received responses up to this token. After sending this token, earlier tokens may not be used anymore.

The server may close the stream if there are too many unacknowledged responses.

Leave this field unset when creating a new stream. To resume a stream at a specific point, set this field and the stream_id field.

Leave this field unset when creating a new stream.

labels

map<string, string>

Labels associated with this write request.

WriteResponse

The response for Firestore.Write.

Fields
stream_id

string

The ID of the stream. Only set on the first message, when a new stream was created.

stream_token

bytes

A token that represents the position of this response in the stream. This can be used by a client to resume the stream at this point.

This field is always set.

write_results[]

WriteResult

The result of applying the writes.

This i-th write result corresponds to the i-th write in the request.

commit_time

Timestamp

The time at which the commit occurred.

WriteResult

The result of applying a write.

Fields
update_time

Timestamp

The last update time of the document after applying the write. Not set after a delete.

If the write did not actually change the document, this will be the previous update_time.

transform_results[]

Value

The results of applying each DocumentTransform.FieldTransform, in the same order.

Was this page helpful? Let us know how we did: