Skip to main content

fields

Creates, updates, deletes, gets or lists a fields resource.

Overview

Namefields
TypeResource
Idgoogle.firestore.fields

Fields

NameDatatypeDescription
namestringRequired. A field name of the form: projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path} A field path can be a simple field name, e.g. address or a path to fields within map_value , e.g. address.city, or a special field path. The only valid special field is *, which represents any field. Field paths can be quoted using ` (backtick). The only character that must be escaped within a quoted field path is the backtick character itself, escaped using a backslash. Special characters in field paths that must be quoted include: *, ., ` (backtick), [, ], as well as any ascii symbolic characters. Examples: `address.city` represents a field named address.city, not the map key city in the field address. `*` represents a field named *, not any field. A special Field contains the default indexing settings for all fields. This field's resource name is: projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/* Indexes defined on this Field will be applied to all fields which do not have their own Field index configuration.
indexConfigobjectThe index configuration for this field.
ttlConfigobjectThe TTL (time-to-live) configuration for documents that have this Field set. Storing a timestamp value into a TTL-enabled field will be treated as the document's absolute expiration time. Timestamp values in the past indicate that the document is eligible for immediate expiration. Using any other data type or leaving the field absent will disable expiration for the individual document.

Methods

NameAccessible byRequired ParamsDescription
getSELECTcollectionGroupsId, databasesId, fieldsId, projectsIdGets the metadata and configuration for a Field.
listSELECTcollectionGroupsId, databasesId, projectsIdLists the field configuration and metadata for this database. Currently, FirestoreAdmin.ListFields only supports listing fields that have been explicitly overridden. To issue this query, call FirestoreAdmin.ListFields with the filter set to indexConfig.usesAncestorConfig:false or ttlConfig:*.
patchUPDATEcollectionGroupsId, databasesId, fieldsId, projectsIdUpdates a field configuration. Currently, field updates apply only to single field index configuration. However, calls to FirestoreAdmin.UpdateField should provide a field mask to avoid changing any configuration that the caller isn't aware of. The field mask should be specified as: { paths: "index_config" }. This call returns a google.longrunning.Operation which may be used to track the status of the field update. The metadata for the operation will be the type FieldOperationMetadata. To configure the default field settings for the database, use the special Field with resource name: projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*.

SELECT examples

Lists the field configuration and metadata for this database. Currently, FirestoreAdmin.ListFields only supports listing fields that have been explicitly overridden. To issue this query, call FirestoreAdmin.ListFields with the filter set to indexConfig.usesAncestorConfig:false or ttlConfig:*.

SELECT
name,
indexConfig,
ttlConfig
FROM google.firestore.fields
WHERE collectionGroupsId = '{{ collectionGroupsId }}'
AND databasesId = '{{ databasesId }}'
AND projectsId = '{{ projectsId }}';

UPDATE example

Updates a fields resource.

/*+ update */
UPDATE google.firestore.fields
SET
name = '{{ name }}',
indexConfig = '{{ indexConfig }}',
ttlConfig = '{{ ttlConfig }}'
WHERE
collectionGroupsId = '{{ collectionGroupsId }}'
AND databasesId = '{{ databasesId }}'
AND fieldsId = '{{ fieldsId }}'
AND projectsId = '{{ projectsId }}';