FirestoreAdminClient

FirestoreAdminClient

Operations are created by service FirestoreAdmin, but are accessed via service google.longrunning.Operations.

Constructor

new FirestoreAdminClient(optionsopt)

Construct an instance of FirestoreAdminClient.

Parameters:
Name Type Attributes Description
options object <optional>

The configuration object. See the subsequent parameters for more details.

Properties
Name Type Attributes Description
credentials object <optional>

Credentials object.

Properties
Name Type Attributes Description
client_email string <optional>
private_key string <optional>
email string <optional>

Account email address. Required when using a .pem or .p12 keyFilename.

keyFilename string <optional>

Full path to the a .json, .pem, or .p12 key downloaded from the Google Developers Console. If you provide a path to a JSON file, the projectId option below is not necessary. NOTE: .pem and .p12 require you to specify options.email as well.

port number <optional>

The port on which to connect to the remote host.

projectId string <optional>

The project ID from the Google Developer's Console, e.g. 'grape-spaceship-123'. We will also check the environment variable GCLOUD_PROJECT for your project ID. If your app is running in an environment which supports Application Default Credentials, your project ID will be detected automatically.

apiEndpoint string <optional>

The domain name of the API remote host.

Members

apiEndpoint

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

port

The port for this API service.

scopes

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

The DNS address for this API service.

Methods

(async) checkCreateIndexProgress(name) → {Promise}

Check the status of the long running operation returned by the createIndex() method.

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from.

(async) checkExportDocumentsProgress(name) → {Promise}

Check the status of the long running operation returned by the exportDocuments() method.

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from.

(async) checkImportDocumentsProgress(name) → {Promise}

Check the status of the long running operation returned by the importDocuments() method.

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from.

(async) checkUpdateFieldProgress(name) → {Promise}

Check the status of the long running operation returned by the updateField() method.

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from.

close()

Terminate the GRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

collectionGroupPath(project, database, collection) → {string}

Return a fully-qualified collectionGroup resource name string.

Parameters:
Name Type Description
project string
database string
collection string
Returns:
Type Description
string

Resource name string.

createIndex(request, optionsopt) → {Promise}

Creates a composite index. This returns a google.longrunning.Operation which may be used to track the status of the creation. The metadata for the operation will be the type IndexOperationMetadata.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. A parent name of the form projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}

index google.firestore.admin.v1.Index

Required. The composite index to create.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Operation. The promise has a method named "cancel" which cancels the ongoing API call.

databasePath(project, database) → {string}

Return a fully-qualified database resource name string.

Parameters:
Name Type Description
project string
database string
Returns:
Type Description
string

Resource name string.

deleteIndex(request, optionsopt) → {Promise}

Deletes a composite index.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. A name of the form projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Empty. The promise has a method named "cancel" which cancels the ongoing API call.

exportDocuments(request, optionsopt) → {Promise}

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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. Database to export. Should be of the form: projects/{project_id}/databases/{database_id}.

collectionIds Array.<string>

Which collection ids to export. Unspecified means all collections.

outputUriPrefix string

The output URI. Currently only supports Google Cloud Storage URIs of the form: gs://BUCKET_NAME[/NAMESPACE_PATH], where BUCKET_NAME is the name of the Google Cloud Storage bucket and NAMESPACE_PATH is an optional Google Cloud Storage namespace path. When choosing a name, be sure to consider Google Cloud Storage naming guidelines: https://cloud.google.com/storage/docs/naming. If the URI is a bucket (without a namespace path), a prefix will be generated based on the start time.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Operation. The promise has a method named "cancel" which cancels the ongoing API call.

fieldPath(project, database, collection, field) → {string}

Return a fully-qualified field resource name string.

Parameters:
Name Type Description
project string
database string
collection string
field string
Returns:
Type Description
string

Resource name string.

getField(request, optionsopt) → {Promise}

Gets the metadata and configuration for a Field.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. A name of the form projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Field. The promise has a method named "cancel" which cancels the ongoing API call.

getIndex(request, optionsopt) → {Promise}

Gets a composite index.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. A name of the form projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Index. The promise has a method named "cancel" which cancels the ongoing API call.

getProjectId(callback)

Return the project ID used by this class.

Parameters:
Name Type Description
callback function

the callback to be called with the current project Id.

importDocuments(request, optionsopt) → {Promise}

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

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. Database to import into. Should be of the form: projects/{project_id}/databases/{database_id}.

collectionIds Array.<string>

Which collection ids to import. Unspecified means all collections included in the import.

inputUriPrefix string

Location of the exported files. This must match the output_uri_prefix of an ExportDocumentsResponse from an export that has completed successfully. See: google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Operation. The promise has a method named "cancel" which cancels the ongoing API call.

indexPath(project, database, collection, index) → {string}

Return a fully-qualified index resource name string.

Parameters:
Name Type Description
project string
database string
collection string
index string
Returns:
Type Description
string

Resource name string.

initialize() → {Promise}

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

Returns:
Type Description
Promise

A promise that resolves to an authenticated service stub.

listFields(request, optionsopt) → {Promise}

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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. A parent name of the form projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}

filter string

The filter to apply to list results. 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.

pageSize number

The number of results to return.

pageToken string

A page token, returned from a previous call to FirestoreAdmin.ListFields, that may be used to get the next page of results.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is Array of Field. The client library support auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array.

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of Field that corresponds to the one page received from the API server. If the second element is not null it contains the request object of type ListFieldsRequest that can be used to obtain the next page of the results. If it is null, the next page does not exist. The third element contains the raw response received from the API server. Its type is ListFieldsResponse.

    The promise has a method named "cancel" which cancels the ongoing API call.

listFieldsAsync(request, optionsopt) → {Object}

Equivalent to listFields, but returns an iterable object.

for-await-of syntax is used with the iterable to recursively get response element on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. A parent name of the form projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}

filter string

The filter to apply to list results. 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.

pageSize number

The number of results to return.

pageToken string

A page token, returned from a previous call to FirestoreAdmin.ListFields, that may be used to get the next page of results.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Object

An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.

listFieldsStream(request, optionsopt) → {Stream}

Equivalent to listFields, but returns a NodeJS Stream object.

This fetches the paged responses for listFields continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. A parent name of the form projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}

filter string

The filter to apply to list results. 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.

pageSize number

The number of results to return.

pageToken string

A page token, returned from a previous call to FirestoreAdmin.ListFields, that may be used to get the next page of results.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing Field on 'data' event.

See:

listIndexes(request, optionsopt) → {Promise}

Lists composite indexes.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. A parent name of the form projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}

filter string

The filter to apply to list results.

pageSize number

The number of results to return.

pageToken string

A page token, returned from a previous call to FirestoreAdmin.ListIndexes, that may be used to get the next page of results.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is Array of Index. The client library support auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array.

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of Index that corresponds to the one page received from the API server. If the second element is not null it contains the request object of type ListIndexesRequest that can be used to obtain the next page of the results. If it is null, the next page does not exist. The third element contains the raw response received from the API server. Its type is ListIndexesResponse.

    The promise has a method named "cancel" which cancels the ongoing API call.

listIndexesAsync(request, optionsopt) → {Object}

Equivalent to listIndexes, but returns an iterable object.

for-await-of syntax is used with the iterable to recursively get response element on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. A parent name of the form projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}

filter string

The filter to apply to list results.

pageSize number

The number of results to return.

pageToken string

A page token, returned from a previous call to FirestoreAdmin.ListIndexes, that may be used to get the next page of results.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Object

An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.

listIndexesStream(request, optionsopt) → {Stream}

Equivalent to listIndexes, but returns a NodeJS Stream object.

This fetches the paged responses for listIndexes continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. A parent name of the form projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}

filter string

The filter to apply to list results.

pageSize number

The number of results to return.

pageToken string

A page token, returned from a previous call to FirestoreAdmin.ListIndexes, that may be used to get the next page of results.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing Index on 'data' event.

See:

matchCollectionFromCollectionGroupName(collectionGroupName) → {string}

Parse the collection from CollectionGroup resource.

Parameters:
Name Type Description
collectionGroupName string

A fully-qualified path representing CollectionGroup resource.

Returns:
Type Description
string

A string representing the collection.

matchCollectionFromFieldName(fieldName) → {string}

Parse the collection from Field resource.

Parameters:
Name Type Description
fieldName string

A fully-qualified path representing Field resource.

Returns:
Type Description
string

A string representing the collection.

matchCollectionFromIndexName(indexName) → {string}

Parse the collection from Index resource.

Parameters:
Name Type Description
indexName string

A fully-qualified path representing Index resource.

Returns:
Type Description
string

A string representing the collection.

matchDatabaseFromCollectionGroupName(collectionGroupName) → {string}

Parse the database from CollectionGroup resource.

Parameters:
Name Type Description
collectionGroupName string

A fully-qualified path representing CollectionGroup resource.

Returns:
Type Description
string

A string representing the database.

matchDatabaseFromDatabaseName(databaseName) → {string}

Parse the database from Database resource.

Parameters:
Name Type Description
databaseName string

A fully-qualified path representing Database resource.

Returns:
Type Description
string

A string representing the database.

matchDatabaseFromFieldName(fieldName) → {string}

Parse the database from Field resource.

Parameters:
Name Type Description
fieldName string

A fully-qualified path representing Field resource.

Returns:
Type Description
string

A string representing the database.

matchDatabaseFromIndexName(indexName) → {string}

Parse the database from Index resource.

Parameters:
Name Type Description
indexName string

A fully-qualified path representing Index resource.

Returns:
Type Description
string

A string representing the database.

matchFieldFromFieldName(fieldName) → {string}

Parse the field from Field resource.

Parameters:
Name Type Description
fieldName string

A fully-qualified path representing Field resource.

Returns:
Type Description
string

A string representing the field.

matchIndexFromIndexName(indexName) → {string}

Parse the index from Index resource.

Parameters:
Name Type Description
indexName string

A fully-qualified path representing Index resource.

Returns:
Type Description
string

A string representing the index.

matchProjectFromCollectionGroupName(collectionGroupName) → {string}

Parse the project from CollectionGroup resource.

Parameters:
Name Type Description
collectionGroupName string

A fully-qualified path representing CollectionGroup resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromDatabaseName(databaseName) → {string}

Parse the project from Database resource.

Parameters:
Name Type Description
databaseName string

A fully-qualified path representing Database resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromFieldName(fieldName) → {string}

Parse the project from Field resource.

Parameters:
Name Type Description
fieldName string

A fully-qualified path representing Field resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromIndexName(indexName) → {string}

Parse the project from Index resource.

Parameters:
Name Type Description
indexName string

A fully-qualified path representing Index resource.

Returns:
Type Description
string

A string representing the project.

updateField(request, optionsopt) → {Promise}

Updates 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/*.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
field google.firestore.admin.v1.Field

Required. The field to be updated.

updateMask google.protobuf.FieldMask

A mask, relative to the field. If specified, only configuration specified by this field_mask will be updated in the field.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Operation. The promise has a method named "cancel" which cancels the ongoing API call.