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
|
- Source:
Members
(static) apiEndpoint
The DNS address for this API service - same as servicePath(), exists for compatibility reasons.
- Source:
(static) port
The port for this API service.
- Source:
(static) scopes
The scopes needed to make gRPC calls for every method defined in this service.
- Source:
(static) servicePath
The DNS address for this API service.
- Source:
Methods
createIndex(request, optionsopt, callbackopt) → {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
|
||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
|||||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing Operation. |
- Source:
Example
const firestore = require('@google-cloud/firestore');
const client = new firestore.v1.FirestoreAdminClient({
// optional auth parameters.
});
const formattedParent = client.parentPath('[PROJECT]', '[DATABASE]', '[COLLECTION_ID]');
const index = {};
const request = {
parent: formattedParent,
index: index,
};
client.createIndex(request)
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
databasePath(project, database) → {String}
Return a fully-qualified database resource name string.
Parameters:
Name | Type | Description |
---|---|---|
project |
String | |
database |
String |
- Source:
deleteIndex(request, optionsopt, callbackopt) → {Promise}
Deletes a composite index.
Parameters:
Name | Type | Attributes | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. |
- Source:
Example
const firestore = require('@google-cloud/firestore');
const client = new firestore.v1.FirestoreAdminClient({
// optional auth parameters.
});
const formattedName = client.indexPath('[PROJECT]', '[DATABASE]', '[COLLECTION_ID]', '[INDEX_ID]');
client.deleteIndex({name: formattedName}).catch(err => {
console.error(err);
});
exportDocuments(request, optionsopt, callbackopt) → {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
|
|||||||||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing Operation. |
- Source:
Example
const firestore = require('@google-cloud/firestore');
const client = new firestore.v1.FirestoreAdminClient({
// optional auth parameters.
});
const formattedName = client.databasePath('[PROJECT]', '[DATABASE]');
client.exportDocuments({name: formattedName})
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
fieldPath(project, database, collectionId, fieldId) → {String}
Return a fully-qualified field resource name string.
Parameters:
Name | Type | Description |
---|---|---|
project |
String | |
database |
String | |
collectionId |
String | |
fieldId |
String |
- Source:
getField(request, optionsopt, callbackopt) → {Promise}
Gets the metadata and configuration for a Field.
Parameters:
Name | Type | Attributes | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing Field. |
- Source:
Example
const firestore = require('@google-cloud/firestore');
const client = new firestore.v1.FirestoreAdminClient({
// optional auth parameters.
});
const formattedName = client.fieldPath('[PROJECT]', '[DATABASE]', '[COLLECTION_ID]', '[FIELD_ID]');
client.getField({name: formattedName})
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
getIndex(request, optionsopt, callbackopt) → {Promise}
Gets a composite index.
Parameters:
Name | Type | Attributes | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing Index. |
- Source:
Example
const firestore = require('@google-cloud/firestore');
const client = new firestore.v1.FirestoreAdminClient({
// optional auth parameters.
});
const formattedName = client.indexPath('[PROJECT]', '[DATABASE]', '[COLLECTION_ID]', '[INDEX_ID]');
client.getIndex({name: formattedName})
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
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. |
- Source:
importDocuments(request, optionsopt, callbackopt) → {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
|
|||||||||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing Operation. |
- Source:
Example
const firestore = require('@google-cloud/firestore');
const client = new firestore.v1.FirestoreAdminClient({
// optional auth parameters.
});
const formattedName = client.databasePath('[PROJECT]', '[DATABASE]');
client.importDocuments({name: formattedName})
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
indexPath(project, database, collectionId, indexId) → {String}
Return a fully-qualified index resource name string.
Parameters:
Name | Type | Description |
---|---|---|
project |
String | |
database |
String | |
collectionId |
String | |
indexId |
String |
- Source:
listFields(request, optionsopt, callbackopt) → {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
|
|||||||||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. The second parameter to the callback is Array of Field. When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListFieldsResponse. |
- Source:
Example
const firestore = require('@google-cloud/firestore');
const client = new firestore.v1.FirestoreAdminClient({
// optional auth parameters.
});
// Iterate over all elements.
const formattedParent = client.parentPath('[PROJECT]', '[DATABASE]', '[COLLECTION_ID]');
client.listFields({parent: formattedParent})
.then(responses => {
const resources = responses[0];
for (const resource of resources) {
// doThingsWith(resource)
}
})
.catch(err => {
console.error(err);
});
// Or obtain the paged response.
const formattedParent = client.parentPath('[PROJECT]', '[DATABASE]', '[COLLECTION_ID]');
const options = {autoPaginate: false};
const callback = responses => {
// The actual resources in a response.
const resources = responses[0];
// The next request if the response shows that there are more responses.
const nextRequest = responses[1];
// The actual response object, if necessary.
// const rawResponse = responses[2];
for (const resource of resources) {
// doThingsWith(resource);
}
if (nextRequest) {
// Fetch the next page.
return client.listFields(nextRequest, options).then(callback);
}
}
client.listFields({parent: formattedParent}, options)
.then(callback)
.catch(err => {
console.error(err);
});
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
|
|||||||||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
Example
const firestore = require('@google-cloud/firestore');
const client = new firestore.v1.FirestoreAdminClient({
// optional auth parameters.
});
const formattedParent = client.parentPath('[PROJECT]', '[DATABASE]', '[COLLECTION_ID]');
client.listFieldsStream({parent: formattedParent})
.on('data', element => {
// doThingsWith(element)
}).on('error', err => {
console.log(err);
});
listIndexes(request, optionsopt, callbackopt) → {Promise}
Lists composite indexes.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. The second parameter to the callback is Array of Index. When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListIndexesResponse. |
- Source:
Example
const firestore = require('@google-cloud/firestore');
const client = new firestore.v1.FirestoreAdminClient({
// optional auth parameters.
});
// Iterate over all elements.
const formattedParent = client.parentPath('[PROJECT]', '[DATABASE]', '[COLLECTION_ID]');
client.listIndexes({parent: formattedParent})
.then(responses => {
const resources = responses[0];
for (const resource of resources) {
// doThingsWith(resource)
}
})
.catch(err => {
console.error(err);
});
// Or obtain the paged response.
const formattedParent = client.parentPath('[PROJECT]', '[DATABASE]', '[COLLECTION_ID]');
const options = {autoPaginate: false};
const callback = responses => {
// The actual resources in a response.
const resources = responses[0];
// The next request if the response shows that there are more responses.
const nextRequest = responses[1];
// The actual response object, if necessary.
// const rawResponse = responses[2];
for (const resource of resources) {
// doThingsWith(resource);
}
if (nextRequest) {
// Fetch the next page.
return client.listIndexes(nextRequest, options).then(callback);
}
}
client.listIndexes({parent: formattedParent}, options)
.then(callback)
.catch(err => {
console.error(err);
});
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
|
|||||||||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
Example
const firestore = require('@google-cloud/firestore');
const client = new firestore.v1.FirestoreAdminClient({
// optional auth parameters.
});
const formattedParent = client.parentPath('[PROJECT]', '[DATABASE]', '[COLLECTION_ID]');
client.listIndexesStream({parent: formattedParent})
.on('data', element => {
// doThingsWith(element)
}).on('error', err => {
console.log(err);
});
matchCollectionIdFromFieldName(fieldName) → {String}
Parse the fieldName from a field resource.
Parameters:
Name | Type | Description |
---|---|---|
fieldName |
String |
A fully-qualified path representing a field resources. |
- Source:
matchCollectionIdFromIndexName(indexName) → {String}
Parse the indexName from a index resource.
Parameters:
Name | Type | Description |
---|---|---|
indexName |
String |
A fully-qualified path representing a index resources. |
- Source:
matchCollectionIdFromParentName(parentName) → {String}
Parse the parentName from a parent resource.
Parameters:
Name | Type | Description |
---|---|---|
parentName |
String |
A fully-qualified path representing a parent resources. |
- Source:
matchDatabaseFromDatabaseName(databaseName) → {String}
Parse the databaseName from a database resource.
Parameters:
Name | Type | Description |
---|---|---|
databaseName |
String |
A fully-qualified path representing a database resources. |
- Source:
matchDatabaseFromFieldName(fieldName) → {String}
Parse the fieldName from a field resource.
Parameters:
Name | Type | Description |
---|---|---|
fieldName |
String |
A fully-qualified path representing a field resources. |
- Source:
matchDatabaseFromIndexName(indexName) → {String}
Parse the indexName from a index resource.
Parameters:
Name | Type | Description |
---|---|---|
indexName |
String |
A fully-qualified path representing a index resources. |
- Source:
matchDatabaseFromParentName(parentName) → {String}
Parse the parentName from a parent resource.
Parameters:
Name | Type | Description |
---|---|---|
parentName |
String |
A fully-qualified path representing a parent resources. |
- Source:
matchFieldIdFromFieldName(fieldName) → {String}
Parse the fieldName from a field resource.
Parameters:
Name | Type | Description |
---|---|---|
fieldName |
String |
A fully-qualified path representing a field resources. |
- Source:
matchIndexIdFromIndexName(indexName) → {String}
Parse the indexName from a index resource.
Parameters:
Name | Type | Description |
---|---|---|
indexName |
String |
A fully-qualified path representing a index resources. |
- Source:
matchProjectFromDatabaseName(databaseName) → {String}
Parse the databaseName from a database resource.
Parameters:
Name | Type | Description |
---|---|---|
databaseName |
String |
A fully-qualified path representing a database resources. |
- Source:
matchProjectFromFieldName(fieldName) → {String}
Parse the fieldName from a field resource.
Parameters:
Name | Type | Description |
---|---|---|
fieldName |
String |
A fully-qualified path representing a field resources. |
- Source:
matchProjectFromIndexName(indexName) → {String}
Parse the indexName from a index resource.
Parameters:
Name | Type | Description |
---|---|---|
indexName |
String |
A fully-qualified path representing a index resources. |
- Source:
matchProjectFromParentName(parentName) → {String}
Parse the parentName from a parent resource.
Parameters:
Name | Type | Description |
---|---|---|
parentName |
String |
A fully-qualified path representing a parent resources. |
- Source:
parentPath(project, database, collectionId) → {String}
Return a fully-qualified parent resource name string.
Parameters:
Name | Type | Description |
---|---|---|
project |
String | |
database |
String | |
collectionId |
String |
- Source:
updateField(request, optionsopt, callbackopt) → {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
|
|||||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing Operation. |
- Source:
Example
const firestore = require('@google-cloud/firestore');
const client = new firestore.v1.FirestoreAdminClient({
// optional auth parameters.
});
const field = {};
client.updateField({field: field})
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});