Constructor
new TabularApiSurface(instance, id)
Parameters:
Name | Type | Description |
---|---|---|
instance |
Instance |
Instance Object. |
id |
string |
Unique identifier of the table. |
Methods
createReadStream(optionsopt) → {stream}
Get Row objects for the rows currently in your table as a readable object stream.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Configuration object. Properties
|
Returns:
Type | Description |
---|---|
stream |
Example
table
.createReadStream()
.on('error', err => {
// Handle the error.
})
.on('data', row => {
// `row` is a Row object.
})
.on('end', () => {
// All rows retrieved.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing.
//-
// table
// .createReadStream()
// .on('data', function (row) {
// this.end();
// });
//-
// Specify arbitrary keys for a non-contiguous set of rows.
// The total size of the keys must remain under 1MB, after encoding.
//-
// table.createReadStream({
// keys: [
// 'alincoln',
// 'gwashington'
// ]
// });
//-
// Scan for row keys that contain a specific prefix.
//-
// table.createReadStream({
// prefix: 'gwash'
// });
//-
// Specify a contiguous range of rows to read by supplying `start` and `end`
// keys.
//
// If the `start` key is omitted, it is interpreted as an empty string.
// If the `end` key is omitted, it is interpreted as infinity.
//-
// table.createReadStream({
// start: 'alincoln',
// end: 'gwashington'
// });
//-
// Specify multiple ranges.
//-
// table.createReadStream({
// ranges: [{
// start: 'alincoln',
// end: 'gwashington'
// }, {
// start: 'tjefferson',
// end: 'jadams'
// }]
// });
//-
// Apply a Filter to the contents of the specified rows.
//-
// table.createReadStream({
// filter: [
// {
// column: 'gwashington'
// }, {
// value: 1
// }
// ]
// });
//
getRows(optionsopt, callback)
Get Row objects for the rows currently in your table.
This method is not recommended for large datasets as it will buffer all rows before returning the results. Instead we recommend using the streaming API via Table#createReadStream.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Configuration object. See Table#createReadStream for a complete list of options. Properties
|
||||||||||||
callback |
function |
The callback function. Properties
|
Example
const options = {
keys: ['alincoln', 'gwashington'],
};
table
.getRows(options)
.then(result => {
const rows = result[0];
})
.catch(err => {
// Handle the error.
});
insert(entries, gaxOptionsopt, callback)
Insert or update rows in your table. It should be noted that gRPC only allows you to send payloads that are less than or equal to 4MB. If you're inserting more than that you may need to send smaller individual requests.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
entries |
object | Array.<object> |
List of entries to be inserted. See Table#mutate. |
|||||||||||||||
gaxOptions |
object |
<optional> |
Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html. |
||||||||||||||
callback |
function |
The callback function. Properties
|
Example
const entries = [
{
key: 'alincoln',
data: {
follows: {
gwashington: 1,
},
},
},
];
table
.insert(entries)
.then(result => {
const apiResponse = result[0];
})
.catch(err => {
// Handle the error.
});
mutate(entries, optionsopt, callback)
Apply a set of changes to be atomically applied to the specified row(s). Mutations are applied in order, meaning that earlier mutations can be masked by later ones.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
entries |
object | Array.<object> |
List of entities to be inserted or deleted. |
|||||||||||||||
options |
object |
<optional> |
Configuration object. Properties
|
||||||||||||||
callback |
function |
The callback function. Properties
|
Example
const entries = [
{
method: 'delete',
key: 'alincoln',
},
];
table
.mutate(entries)
.then(() => {
// handle success
})
.catch(err => {
// Handle the error.
});
row(key) → {Row}
Get a reference to a table row.
Parameters:
Name | Type | Description |
---|---|---|
key |
string |
The row key. |
Returns:
Type | Description |
---|---|
Row |
Throws:
-
If a key is not provided.
- Type
- error
sampleRowKeys(gaxOptionsopt, callbackopt)
Returns a sample of row keys in the table. The returned row keys will delimit contiguous sections of the table of approximately equal size, which can be used to break up the data for distributed tasks like mapreduces.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
gaxOptions |
object |
<optional> |
Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html. |
||||||||||||
callback |
function |
<optional> |
The callback function. Properties
|
Example
table
.sampleRowKeys()
.then(result => {
const sampleRKeys = result[0];
})
.catch(err => {
// Handle the error.
});
sampleRowKeysStream(gaxOptionsopt) → {stream}
Returns a sample of row keys in the table as a readable object stream.
See Table#sampleRowKeys for more details.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
gaxOptions |
object |
<optional> |
Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html. |
Returns:
Type | Description |
---|---|
stream |
Example
```
table.sampleRowKeysStream()
.on('error', console.error)
.on('data', function(key) {
// Do something with the `key` object.
});
//-
// If you anticipate many results, you can end a stream early to prevent
// unnecessary processing.
//-
table.sampleRowKeysStream()
.on('data', function(key) {
this.end();
});
```