Methods
createReadStream(keys, optionsopt)
Retrieve the entities as a readable object stream.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
keys |
Key | Array.<Key> |
Datastore key object(s). |
|
options |
object |
<optional> |
Optional configuration. See Datastore#get for a complete list of options. |
Throws:
-
-
If at least one Key object is not provided.
- Type
- Error
-
-
-
If read time and read consistency cannot both be specified.
- Type
- Error
-
Example
```
const keys = [
datastore.key(['Company', 123]),
datastore.key(['Product', 'Computer'])
];
datastore.createReadStream(keys)
.on('error', (err) => {})
.on('data', (entity) => {
// entity is an entity object.
})
.on('end', () => {
// All entities retrieved.
});
```
parseTransactionResponse(responseopt)
This function saves results from a successful beginTransaction call.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
response |
BeginAsyncResponse |
<optional> |
The response from a call to begin a transaction that completed successfully. |
requestStream_(config)
Make a request as a stream.
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
object |
Configuration object. Properties
|
runQueryStream(query, optionsopt)
Get a list of entities as a readable object stream.
See Datastore#runQuery for a list of all available options.
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
query |
Query |
Query object. |
|||||||||
options |
object |
<optional> |
Optional configuration. Properties
|
Throws:
-
If read time and read consistency cannot both be specified.
- Type
- Error
Example
```
datastore.runQueryStream(query)
.on('error', console.error)
.on('data', (entity) => {
// Access the Key object for this entity.
const key = entity[datastore.KEY];
})
.on('info', (info) => {})
.on('end', () => {
// All entities retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing and API requests.
//-
datastore.runQueryStream(query)
.on('data', (entity) => {
this.end();
});
```
(static) prepareEntityObject_(obj)
Format a user's input to mutation methods. This will create a deep clone of the input, as well as allow users to pass an object in the format of an entity.
Both of the following formats can be supplied supported:
datastore.save({
key: datastore.key('Kind'),
data: { foo: 'bar' }
}, (err) => {})
const entity = { foo: 'bar' }
entity[datastore.KEY] = datastore.key('Kind')
datastore.save(entity, (err) => {})
Parameters:
Name | Type | Description |
---|---|---|
obj |
object |
The user's input object. |