class ProjectsDatabasesDocuments extends Resource (View source)

The "documents" collection of methods.

Typical usage is:

 $firestoreService = new Google\Service\Firestore(...);
 $documents = $firestoreService->projects_databases_documents;

Methods

batchGet(string $database, BatchGetDocumentsRequest $postBody, array $optParams = [])

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

batchWrite(string $database, BatchWriteRequest $postBody, array $optParams = [])

Applies a batch of write operations. The BatchWrite method does not apply the write operations atomically and can apply them out of order. Method does not allow more than one write per document. Each write succeeds or fails independently. See the BatchWriteResponse for the success status of each write. If you require an atomically applied set of writes, use Commit instead. (documents.batchWrite)

beginTransaction(string $database, BeginTransactionRequest $postBody, array $optParams = [])

Starts a new transaction. (documents.beginTransaction)

commit(string $database, CommitRequest $postBody, array $optParams = [])

Commits a transaction, while optionally updating documents.

createDocument(string $parent, string $collectionId, Document $postBody, array $optParams = [])

Creates a new document. (documents.createDocument)

delete(string $name, array $optParams = [])

Deletes a document. (documents.delete)

get(string $name, array $optParams = [])

Gets a single document. (documents.get)

listProjectsDatabasesDocuments(string $parent, string $collectionId, array $optParams = [])

Lists documents. (documents.listProjectsDatabasesDocuments)

listCollectionIds(string $parent, ListCollectionIdsRequest $postBody, array $optParams = [])

Lists all the collection IDs underneath a document.

listDocuments(string $parent, string $collectionId, array $optParams = [])

Lists documents. (documents.listDocuments)

listen(string $database, ListenRequest $postBody, array $optParams = [])

Listens to changes. This method is only available via gRPC or WebChannel (not REST). (documents.listen)

partitionQuery(string $parent, PartitionQueryRequest $postBody, array $optParams = [])

Partitions a query by returning partition cursors that can be used to run the query in parallel. The returned partition cursors are split points that can be used by RunQuery as starting/end points for the query results.

patch(string $name, Document $postBody, array $optParams = [])

Updates or inserts a document. (documents.patch)

rollback(string $database, RollbackRequest $postBody, array $optParams = [])

Rolls back a transaction. (documents.rollback)

runAggregationQuery(string $parent, RunAggregationQueryRequest $postBody, array $optParams = [])

Runs an aggregation query. Rather than producing Document results like Firestore.RunQuery, this API allows running an aggregation to produce a series of AggregationResult server-side. High-Level Example: -- Return the number of documents in table given a filter. SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); (documents.runAggregationQuery)

runQuery(string $parent, RunQueryRequest $postBody, array $optParams = [])

Runs a query. (documents.runQuery)

write(string $database, WriteRequest $postBody, array $optParams = [])

Streams batches of document updates and deletes, in order. This method is only available via gRPC or WebChannel (not REST). (documents.write)

Details

BatchGetDocumentsResponse batchGet(string $database, BatchGetDocumentsRequest $postBody, array $optParams = [])

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

(documents.batchGet)

Parameters

string $database

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

BatchGetDocumentsRequest $postBody
array $optParams

Optional parameters.

Return Value

BatchGetDocumentsResponse

Exceptions

Exception

BatchWriteResponse batchWrite(string $database, BatchWriteRequest $postBody, array $optParams = [])

Applies a batch of write operations. The BatchWrite method does not apply the write operations atomically and can apply them out of order. Method does not allow more than one write per document. Each write succeeds or fails independently. See the BatchWriteResponse for the success status of each write. If you require an atomically applied set of writes, use Commit instead. (documents.batchWrite)

Parameters

string $database

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

BatchWriteRequest $postBody
array $optParams

Optional parameters.

Return Value

BatchWriteResponse

Exceptions

Exception

BeginTransactionResponse beginTransaction(string $database, BeginTransactionRequest $postBody, array $optParams = [])

Starts a new transaction. (documents.beginTransaction)

Parameters

string $database

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

BeginTransactionRequest $postBody
array $optParams

Optional parameters.

Return Value

BeginTransactionResponse

Exceptions

Exception

CommitResponse commit(string $database, CommitRequest $postBody, array $optParams = [])

Commits a transaction, while optionally updating documents.

(documents.commit)

Parameters

string $database

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

CommitRequest $postBody
array $optParams

Optional parameters.

Return Value

CommitResponse

Exceptions

Exception

Document createDocument(string $parent, string $collectionId, Document $postBody, array $optParams = [])

Creates a new document. (documents.createDocument)

Parameters

string $parent

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

string $collectionId

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

Document $postBody
array $optParams

Optional parameters.

Return Value

Document

Exceptions

Exception

FirestoreEmpty delete(string $name, array $optParams = [])

Deletes a document. (documents.delete)

Parameters

string $name

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

array $optParams

Optional parameters.

Return Value

FirestoreEmpty

Exceptions

Exception

Document get(string $name, array $optParams = [])

Gets a single document. (documents.get)

Parameters

string $name

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

array $optParams

Optional parameters.

Return Value

Document

Exceptions

Exception

ListDocumentsResponse listProjectsDatabasesDocuments(string $parent, string $collectionId, array $optParams = [])

Lists documents. (documents.listProjectsDatabasesDocuments)

Parameters

string $parent

Required. 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

string $collectionId

Optional. The collection ID, relative to parent, to list. For example: chatrooms or messages. This is optional, and when not provided, Firestore will list documents from all collections under the provided parent.

array $optParams

Optional parameters.

Return Value

ListDocumentsResponse

Exceptions

Exception

ListCollectionIdsResponse listCollectionIds(string $parent, ListCollectionIdsRequest $postBody, array $optParams = [])

Lists all the collection IDs underneath a document.

(documents.listCollectionIds)

Parameters

string $parent

Required. 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

ListCollectionIdsRequest $postBody
array $optParams

Optional parameters.

Return Value

ListCollectionIdsResponse

Exceptions

Exception

ListDocumentsResponse listDocuments(string $parent, string $collectionId, array $optParams = [])

Lists documents. (documents.listDocuments)

Parameters

string $parent

Required. 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

string $collectionId

Optional. The collection ID, relative to parent, to list. For example: chatrooms or messages. This is optional, and when not provided, Firestore will list documents from all collections under the provided parent.

array $optParams

Optional parameters.

Return Value

ListDocumentsResponse

Exceptions

Exception

ListenResponse listen(string $database, ListenRequest $postBody, array $optParams = [])

Listens to changes. This method is only available via gRPC or WebChannel (not REST). (documents.listen)

Parameters

string $database

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

ListenRequest $postBody
array $optParams

Optional parameters.

Return Value

ListenResponse

Exceptions

Exception

PartitionQueryResponse partitionQuery(string $parent, PartitionQueryRequest $postBody, array $optParams = [])

Partitions a query by returning partition cursors that can be used to run the query in parallel. The returned partition cursors are split points that can be used by RunQuery as starting/end points for the query results.

(documents.partitionQuery)

Parameters

string $parent

Required. The parent resource name. In the format: projects/{project_id}/databases/{database_id}/documents. Document resource names are not supported; only database resource names can be specified.

PartitionQueryRequest $postBody
array $optParams

Optional parameters.

Return Value

PartitionQueryResponse

Exceptions

Exception

Document patch(string $name, Document $postBody, array $optParams = [])

Updates or inserts a document. (documents.patch)

Parameters

string $name

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

Document $postBody
array $optParams

Optional parameters.

Return Value

Document

Exceptions

Exception

FirestoreEmpty rollback(string $database, RollbackRequest $postBody, array $optParams = [])

Rolls back a transaction. (documents.rollback)

Parameters

string $database

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

RollbackRequest $postBody
array $optParams

Optional parameters.

Return Value

FirestoreEmpty

Exceptions

Exception

RunAggregationQueryResponse runAggregationQuery(string $parent, RunAggregationQueryRequest $postBody, array $optParams = [])

Runs an aggregation query. Rather than producing Document results like Firestore.RunQuery, this API allows running an aggregation to produce a series of AggregationResult server-side. High-Level Example: -- Return the number of documents in table given a filter. SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); (documents.runAggregationQuery)

Parameters

string $parent

Required. 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

RunAggregationQueryRequest $postBody
array $optParams

Optional parameters.

Return Value

RunAggregationQueryResponse

Exceptions

Exception

RunQueryResponse runQuery(string $parent, RunQueryRequest $postBody, array $optParams = [])

Runs a query. (documents.runQuery)

Parameters

string $parent

Required. 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

RunQueryRequest $postBody
array $optParams

Optional parameters.

Return Value

RunQueryResponse

Exceptions

Exception

WriteResponse write(string $database, WriteRequest $postBody, array $optParams = [])

Streams batches of document updates and deletes, in order. This method is only available via gRPC or WebChannel (not REST). (documents.write)

Parameters

string $database

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

WriteRequest $postBody
array $optParams

Optional parameters.

Return Value

WriteResponse

Exceptions

Exception