Skip to main content

databases

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

Overview

Namedatabases
TypeResource
Idgoogle.firestore.databases

Fields

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
namestringThe resource name of the Database. Format: projects/{project}/databases/{database}
appEngineIntegrationModestringThe App Engine integration mode to use for this database.
cmekConfigobjectOptional. Presence indicates CMEK is enabled for this database. (id: GoogleFirestoreAdminV1CmekConfig)
concurrencyModestringThe concurrency control mode to use for this database.
createTimestring (google-datetime)Output only. The timestamp at which this database was created. Databases created before 2016 do not populate create_time.
databaseEditionstringImmutable. The edition of the database.
deleteProtectionStatestringState of delete protection for the database.
deleteTimestring (google-datetime)Output only. The timestamp at which this database was deleted. Only set if the database has been deleted.
earliestVersionTimestring (google-datetime)Output only. The earliest timestamp at which older versions of the data can be read from the database. See [version_retention_period] above; this field is populated with now - version_retention_period. This value is continuously updated, and becomes stale the moment it is queried. If you are using this value to recover data, make sure to account for the time from the moment when the value is queried to the moment when you initiate the recovery.
etagstringThis checksum is computed by the server based on the value of other fields, and may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding.
freeTierbooleanOutput only. Background: Free tier is the ability of a Firestore database to use a small amount of resources every day without being charged. Once usage exceeds the free tier limit further usage is charged. Whether this database can make use of the free tier. Only one database per project can be eligible for the free tier. The first (or next) database that is created in a project without a free tier database will be marked as eligible for the free tier. Databases that are created while there is a free tier database will not be eligible for the free tier.
keyPrefixstringOutput only. The key_prefix for this database. This key_prefix is used, in combination with the project ID ("") to construct the application ID that is returned from the Cloud Datastore APIs in Google App Engine first generation runtimes. This value may be empty in which case the appid to use for URL-encoded keys is the project_id (eg: foo instead of vfoo).
locationIdstringThe location of the database. Available locations are listed at https://cloud.google.com/firestore/docs/locations.
pointInTimeRecoveryEnablementstringWhether to enable the PITR feature on this database.
previousIdstringOutput only. The database resource's prior database ID. This field is only populated for deleted databases.
sourceInfoobjectOutput only. Information about the provenance of this database. (id: GoogleFirestoreAdminV1SourceInfo)
tagsobjectOptional. Input only. Immutable. Tag keys/values directly bound to this resource. For example: "123/environment": "production", "123/costCenter": "marketing"
typestringThe type of the database. See https://cloud.google.com/datastore/docs/firestore-or-datastore for information about how to choose.
uidstringOutput only. The system-generated UUID4 for this Database.
updateTimestring (google-datetime)Output only. The timestamp at which this database was most recently updated. Note this only includes updates to the database resource and not data contained by the database.
versionRetentionPeriodstring (google-duration)Output only. The period during which past versions of data are retained in the database. Any read or query can specify a read_time within this window, and will read the state of the database at that time. If the PITR feature is enabled, the retention period is 7 days. Otherwise, the retention period is 1 hour.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectprojectsId, databasesIdGets information about a database.
listselectprojectsIdshowDeletedList all the databases in the project.
createinsertprojectsIddatabaseIdCreate a database.
patchupdateprojectsId, databasesIdupdateMaskUpdates a database.
bulk_delete_documentsdeleteprojectsId, databasesIdBulk deletes a subset of documents from Google Cloud Firestore. Documents created or updated after the underlying system starts to process the request will not be deleted. The bulk delete occurs in the background and its progress can be monitored and managed via the Operation resource that is created. For more details on bulk delete behavior, refer to: https://cloud.google.com/firestore/docs/manage-data/bulk-delete
deletedeleteprojectsId, databasesIdetagDeletes a database.
export_documentsexecprojectsId, databasesIdExports a copy of all or a subset of documents from Google Cloud Firestore to another storage system, such as Google Cloud Storage. Recent updates to documents may not be reflected in the export. The export occurs in the background and its progress can be monitored and managed via the Operation resource that is created. The output of an export may only be used once the associated operation is done. If an export operation is cancelled before completion it may leave partial data behind in Google Cloud Storage. For more details on export behavior and output format, refer to: https://cloud.google.com/firestore/docs/manage-data/export-import
import_documentsexecprojectsId, databasesIdImports documents into Google Cloud Firestore. Existing documents with the same name are overwritten. The import occurs in the background and its progress can be monitored and managed via the Operation resource that is created. If an ImportDocuments operation is cancelled, it is possible that a subset of the data has already been imported to Cloud Firestore.
restoreexecprojectsIdCreates a new database by restoring from an existing backup. The new database must be in the same cloud region or multi-region location as the existing backup. This behaves similar to FirestoreAdmin.CreateDatabase except instead of creating a new empty database, a new database is created with the database type, index configuration, and documents from an existing backup. The long-running operation can be used to track the progress of the restore, with the Operation's metadata field type being the RestoreDatabaseMetadata. The response type is the Database if the restore was successful. The new database is not readable or writeable until the LRO has completed.
cloneexecprojectsIdCreates a new database by cloning an existing one. The new database must be in the same cloud region or multi-region location as the existing database. This behaves similar to FirestoreAdmin.CreateDatabase except instead of creating a new empty database, a new database is created with the database type, index configuration, and documents from an existing database. The long-running operation can be used to track the progress of the clone, with the Operation's metadata field type being the CloneDatabaseMetadata. The response type is the Database if the clone was successful. The new database is not readable or writeable until the LRO has completed.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
databasesIdstring
projectsIdstring
databaseIdstring
etagstring
showDeletedboolean
updateMaskstring (google-fieldmask)

SELECT examples

Gets information about a database.

SELECT
name,
appEngineIntegrationMode,
cmekConfig,
concurrencyMode,
createTime,
databaseEdition,
deleteProtectionState,
deleteTime,
earliestVersionTime,
etag,
freeTier,
keyPrefix,
locationId,
pointInTimeRecoveryEnablement,
previousId,
sourceInfo,
tags,
type,
uid,
updateTime,
versionRetentionPeriod
FROM google.firestore.databases
WHERE projectsId = '{{ projectsId }}' -- required
AND databasesId = '{{ databasesId }}' -- required;

INSERT examples

Create a database.

INSERT INTO google.firestore.databases (
data__name,
data__locationId,
data__type,
data__concurrencyMode,
data__pointInTimeRecoveryEnablement,
data__appEngineIntegrationMode,
data__deleteProtectionState,
data__cmekConfig,
data__tags,
data__etag,
data__databaseEdition,
projectsId,
databaseId
)
SELECT
'{{ name }}',
'{{ locationId }}',
'{{ type }}',
'{{ concurrencyMode }}',
'{{ pointInTimeRecoveryEnablement }}',
'{{ appEngineIntegrationMode }}',
'{{ deleteProtectionState }}',
'{{ cmekConfig }}',
'{{ tags }}',
'{{ etag }}',
'{{ databaseEdition }}',
'{{ projectsId }}',
'{{ databaseId }}'
RETURNING
name,
done,
error,
metadata,
response
;

UPDATE examples

Updates a database.

UPDATE google.firestore.databases
SET
data__name = '{{ name }}',
data__locationId = '{{ locationId }}',
data__type = '{{ type }}',
data__concurrencyMode = '{{ concurrencyMode }}',
data__pointInTimeRecoveryEnablement = '{{ pointInTimeRecoveryEnablement }}',
data__appEngineIntegrationMode = '{{ appEngineIntegrationMode }}',
data__deleteProtectionState = '{{ deleteProtectionState }}',
data__cmekConfig = '{{ cmekConfig }}',
data__tags = '{{ tags }}',
data__etag = '{{ etag }}',
data__databaseEdition = '{{ databaseEdition }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND databasesId = '{{ databasesId }}' --required
AND updateMask = '{{ updateMask}}'
RETURNING
name,
done,
error,
metadata,
response;

DELETE examples

Bulk deletes a subset of documents from Google Cloud Firestore. Documents created or updated after the underlying system starts to process the request will not be deleted. The bulk delete occurs in the background and its progress can be monitored and managed via the Operation resource that is created. For more details on bulk delete behavior, refer to: https://cloud.google.com/firestore/docs/manage-data/bulk-delete

DELETE FROM google.firestore.databases
WHERE projectsId = '{{ projectsId }}' --required
AND databasesId = '{{ databasesId }}' --required;

Lifecycle Methods

Exports a copy of all or a subset of documents from Google Cloud Firestore to another storage system, such as Google Cloud Storage. Recent updates to documents may not be reflected in the export. The export occurs in the background and its progress can be monitored and managed via the Operation resource that is created. The output of an export may only be used once the associated operation is done. If an export operation is cancelled before completion it may leave partial data behind in Google Cloud Storage. For more details on export behavior and output format, refer to: https://cloud.google.com/firestore/docs/manage-data/export-import

EXEC google.firestore.databases.export_documents 
@projectsId='{{ projectsId }}' --required,
@databasesId='{{ databasesId }}' --required
@@json=
'{
"collectionIds": "{{ collectionIds }}",
"outputUriPrefix": "{{ outputUriPrefix }}",
"namespaceIds": "{{ namespaceIds }}",
"snapshotTime": "{{ snapshotTime }}"
}';