Constructor
new DatastoreClient(optionsopt)
Construct an instance of DatastoreClient.
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
allocateIds(request, optionsopt, callbackopt) → {Promise}
Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.
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 AllocateIdsResponse. |
- Source:
Example
const datastore = require('@google-cloud/datastore');
const client = new datastore.v1.DatastoreClient({
// optional auth parameters.
});
const projectId = '';
const keys = [];
const request = {
projectId: projectId,
keys: keys,
};
client.allocateIds(request)
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
beginTransaction(request, optionsopt, callbackopt) → {Promise}
Begins a new transaction.
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 BeginTransactionResponse. |
- Source:
Example
const datastore = require('@google-cloud/datastore');
const client = new datastore.v1.DatastoreClient({
// optional auth parameters.
});
const projectId = '';
client.beginTransaction({projectId: projectId})
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
commit(request, optionsopt, callbackopt) → {Promise}
Commits a transaction, optionally creating, deleting or modifying some entities.
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 CommitResponse. |
- Source:
Example
const datastore = require('@google-cloud/datastore');
const client = new datastore.v1.DatastoreClient({
// optional auth parameters.
});
const projectId = '';
client.commit({projectId: projectId})
.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:
lookup(request, optionsopt, callbackopt) → {Promise}
Looks up entities by key.
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 LookupResponse. |
- Source:
Example
const datastore = require('@google-cloud/datastore');
const client = new datastore.v1.DatastoreClient({
// optional auth parameters.
});
const projectId = '';
const keys = [];
const request = {
projectId: projectId,
keys: keys,
};
client.lookup(request)
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
reserveIds(request, optionsopt, callbackopt) → {Promise}
Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.
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 ReserveIdsResponse. |
- Source:
Example
const datastore = require('@google-cloud/datastore');
const client = new datastore.v1.DatastoreClient({
// optional auth parameters.
});
const projectId = '';
const keys = [];
const request = {
projectId: projectId,
keys: keys,
};
client.reserveIds(request)
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
rollback(request, optionsopt, callbackopt) → {Promise}
Rolls back a transaction.
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 RollbackResponse. |
- Source:
Example
const datastore = require('@google-cloud/datastore');
const client = new datastore.v1.DatastoreClient({
// optional auth parameters.
});
const projectId = '';
const transaction = Buffer.from('');
const request = {
projectId: projectId,
transaction: transaction,
};
client.rollback(request)
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
runQuery(request, optionsopt, callbackopt) → {Promise}
Queries for entities.
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 RunQueryResponse. |
- Source:
Example
const datastore = require('@google-cloud/datastore');
const client = new datastore.v1.DatastoreClient({
// optional auth parameters.
});
const projectId = '';
client.runQuery({projectId: projectId})
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});