listDocuments method
Lists documents.
Request parameters:
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
Value must have pattern ^projects/\[^/\]+/databases/\[^/\]+/documents$.
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.
mask_fieldPaths - The list of field paths in the mask. See
Document.fields for a field path syntax reference.
orderBy - Optional. The optional ordering of the documents to return.
For example: priority desc, __name__ desc. This mirrors the ORDER BY
used in Firestore queries but in a string representation. When absent,
documents are ordered based on __name__ ASC.
pageSize - Optional. The maximum number of documents to return in a
single response. Firestore may return fewer than this value.
pageToken - Optional. A page token, received from a previous
ListDocuments response. Provide this to retrieve the subsequent page.
When paginating, all other parameters (with the exception of page_size)
must match the values set in the request that generated the page token.
readTime - Perform the read at the provided 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.
recursive - Optional. If the list should recursively include all
documents nested under the parent at any level. If the request specifies a
collection_id, then the list will include all nested documents in the
collection under the parent. This is optional, and when not provided,
Firestore will only list documents nested immediately under the parent.
Requests with recursive may not specify show_missing.
requestOptions_requestTags - Optional. The request tags for the request.
Request tags are user-provided strings used for usage monitoring, cost
management, and observability. Callers can associate custom application
context (such as component, microservice, feature name, or operation type)
with database requests. These tags are collected and aggregated in usage
and monitoring reports, allowing billable operations and usage metrics to
be sliced and analyzed by tag. These tags only show up in monitoring and
are visible in administrative operations (such as usage reports). They do
not affect data storage, query semantics, or request execution.
Cardinality and Best Practices: - Request tags are most effective when
using a bounded set of distinct values (e.g., fewer than 100 distinct tags
across an entire database). Using a large number of distinct tags may
result in tags being omitted from top usage dashboards. - Use structured
identifiers (for example: app=cart, env=prod, service=checkout) and
avoid high-cardinality values such as UUIDs, request IDs, timestamps, user
IDs, or document keys. - Do not include sensitive data or personally
identifiable information (PII) in request tags, as they show up in
administrative monitoring. The tags are processed as follows: - Leading
and trailing whitespace is trimmed. - Empty tags (after trimming) are
filtered out. - Truncated to a maximum of 510 characters. - Deduplicated
within the same request. - Limited to a maximum of 50 tags per request
(excess tags are silently discarded).
showMissing - If the list should show missing documents. A document is
missing if it does not exist, but there are sub-documents nested
underneath it. When true, such missing documents will be returned with a
key but will not have fields, create_time, or update_time set.
Requests with show_missing may not specify where or order_by.
transaction - Perform the read as part of an already active transaction.
$fields - Selector specifying which fields to include in a partial
response.
Completes with a ListDocumentsResponse.
Completes with a commons.ApiRequestError if the API endpoint returned an error.
If the used http.Client completes with an error when making a REST call,
this method will complete with the same error.
Implementation
async.Future<ListDocumentsResponse> listDocuments(
core.String parent,
core.String collectionId, {
core.List<core.String>? mask_fieldPaths,
core.String? orderBy,
core.int? pageSize,
core.String? pageToken,
core.String? readTime,
core.bool? recursive,
core.List<core.String>? requestOptions_requestTags,
core.bool? showMissing,
core.String? transaction,
core.String? $fields,
}) async {
final queryParams_ = <core.String, core.List<core.String>>{
'mask.fieldPaths': ?mask_fieldPaths,
'orderBy': ?orderBy == null ? null : [orderBy],
'pageSize': ?pageSize == null ? null : ['${pageSize}'],
'pageToken': ?pageToken == null ? null : [pageToken],
'readTime': ?readTime == null ? null : [readTime],
'recursive': ?recursive == null ? null : ['${recursive}'],
'requestOptions.requestTags': ?requestOptions_requestTags,
'showMissing': ?showMissing == null ? null : ['${showMissing}'],
'transaction': ?transaction == null ? null : [transaction],
'fields': ?$fields == null ? null : [$fields],
};
final url_ =
'v1/' +
core.Uri.encodeFull('$parent') +
'/' +
commons.escapeVariable('$collectionId');
final response_ = await _requester.request(
url_,
'GET',
queryParams: queryParams_,
);
return ListDocumentsResponse.fromJson(
response_ as core.Map<core.String, core.dynamic>,
);
}