Constructor
new Table(instance, id)
Parameters:
Name | Type | Description |
---|---|---|
instance |
Instance |
Instance Object. |
id |
string |
Unique identifier of the table. |
Methods
checkConsistency(token, callback)
Checks consistency for given ConsistencyToken
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
token |
string |
consistency token |
||||||||||||
callback |
function |
The callback function. Properties
|
create(optionsopt, callback)
Create a table.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
See Instance#createTable. Properties
|
||||||||||||||||
callback |
function |
The callback function. Properties
|
Example
table
.create()
.then(result => {
const table = result[0];
// let apiResponse = result[1];
})
.catch(err => {
// Handle the error.
});
createBackup(id, config, callbackopt) → {void|Promise.<CreateBackupResponse>}
Backup a table with cluster auto selection.
Backups of tables originate from a specific cluster. This is a helper
around Cluster.createBackup
that automatically selects the first ready
cluster from which a backup can be performed.
NOTE: This will make two API requests to first determine the most appropriate cluster, then create the backup. This could lead to a race condition if other requests are simultaneously sent or if the cluster availability state changes between each call.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
string |
A unique ID for the backup. |
|||||||||||||||||||||
config |
CreateBackupConfig |
Metadata to set on the Backup. Properties
|
|||||||||||||||||||||
callback |
CreateBackupCallback |
<optional> |
The callback function. Properties
|
Returns:
Type | Description |
---|---|
void | Promise.<CreateBackupResponse> |
createFamily(id, optionsopt, callback)
Create a column family.
Optionally you can send garbage collection rules and when creating a family. Garbage collection executes opportunistically in the background, so it's possible for reads to return a cell even if it matches the active expression for its family.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
string |
The unique identifier of column family. |
|||||||||||||||||||||||||||||||||
options |
object |
<optional> |
Configuration object. Properties
|
||||||||||||||||||||||||||||||||
callback |
function |
The callback function. Properties
|
Throws:
-
If a name is not provided.
- Type
- error
Example
const options = {};
// options.rule = {
// age: {
// seconds: 0,
// nanos: 5000
// },
// versions: 3,
// union: true
// };
table
.createFamily(familyId, options)
.then(result => {
const family = result[0];
// const apiResponse = result[1];
})
.catch(err => {
// Handle the error.
});
delete(gaxOptionsopt, callbackopt)
Delete the table.
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
.delete()
.then(result => {
const apiResponse = result[0];
})
.catch(err => {
// Handle the error.
});
deleteRows(prefix, gaxOptionsopt, callback)
Delete all rows in the table, optionally corresponding to a particular prefix.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
prefix |
string |
Row key prefix. |
|||||||||||||
gaxOptions |
object |
<optional> |
Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html. |
||||||||||||
callback |
function |
The callback function. Properties
|
Throws:
-
If a prefix is not provided.
- Type
- error
Example
table
.deleteRows('alincoln')
.then(result => {
const apiResponse = result[0];
})
.catch(err => {
// Handle the error.
});
exists(gaxOptionsopt, callback)
Check if a table exists.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
gaxOptions |
object |
<optional> |
Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html. |
||||||||||||
callback |
function |
The callback function. Properties
|
Example
table
.exists()
.then(result => {
const exists = result[0];
})
.catch(err => {
// Handle the error.
});
family(id) → {Family}
Get a reference to a Table Family.
Parameters:
Name | Type | Description |
---|---|---|
id |
string |
The family unique identifier. |
Returns:
Type | Description |
---|---|
Family |
Throws:
-
If a name is not provided.
- Type
- error
generateConsistencyToken(callback)
Generates Consistency-Token
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
callback |
function |
The callback function. Properties
|
get(optionsopt)
Get a table if it exists.
You may optionally use this to "get or create" an object by providing an
object with autoCreate
set to true
. Any extra configuration that is
normally required for the create
method must be contained within this
object as well.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Configuration object. Properties
|
|||||||||||||||
callback.error |
error |
<nullable> |
An error returned while making this request. |
|||||||||||||||
callback.table |
Table |
The Table object. |
||||||||||||||||
callback.apiResponse |
object |
The resource as it exists in the API. |
Example
table
.get()
.then(result => {
const table = result[0];
// const apiResponse = result[1];
})
.catch(err => {
// Handle the error.
});
getFamilies(gaxOptionsopt, callback)
Get Family objects for all the column families in your table.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
gaxOptions |
object |
<optional> |
Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html. |
||||||||||||||||
callback |
function |
The callback function. Properties
|
Example
table
.getFamilies()
.then(result => {
const families = result[0];
})
.catch(err => {
// Handle the error.
});
getIamPolicy(optionsopt, callbackopt, policy)
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Configuration object. Properties
|
||||||||||||
callback |
function |
<optional> |
The callback function. Properties
|
||||||||||||
policy |
Policy |
The policy. |
Example
const {Bigtable} = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
const instance = bigtable.instance(instanceId);
const table = instance.table(tableId);
table
.getIamPolicy()
.then(result => {
const policy = result[0];
})
.catch(err => {
// Handle the error.
});
getMetadata(optionsopt, callbackopt)
Get the table's metadata.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Table request options. Properties
|
||||||||||||
callback |
function |
<optional> |
The callback function. Properties
|
Example
table
.getMetadata()
.then(result => {
const metaData = result[0];
// const apiResponse = result[1];
})
.catch(err => {
// Handle the error.
});
getReplicationStates(gaxOptionsopt, callback)
Get replication states of the clusters for this table.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
gaxOptions |
object |
<optional> |
Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html. |
||||||||||||||||
callback |
function |
The callback function. Properties
|
Example
```
const {Bigtable} = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
const instance = bigtable.instance('my-instance');
const table = instance.table('prezzy');
table.getReplicationStates(function(err, clusterStates, apiResponse) {
// `clusterStates` is an map of clusterId and its replication state.
});
//-
// If the callback is omitted, we'll return a Promise.
//-
table.getReplicationStates().then(function(data) {
const clusterStates = data[0];
const apiResponse = data[1];
});
```
setIamPolicy(gaxOptionsopt, callbackopt, policy)
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
|
||||||||
policy |
Policy |
The policy. |
Example
const {Bigtable} = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
const instance = bigtable.instance(instanceId);
const table = instance.table(tableId);
const policy = {
bindings: [
{
role: 'roles/bigtable.viewer',
members: ['user:mike@example.com', 'group:admins@example.com'],
},
],
};
table
.setIamPolicy(policy)
.then(result => {
const setPolicy = result[0];
})
.catch(err => {
// Handle the error
});
testIamPermissions(permissions, gaxOptionsopt, callbackopt, permissions)
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
permissions |
string | Array.<string> |
The permission(s) to test for. |
|||||||||
gaxOptions |
object |
<optional> |
Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html. |
||||||||
callback |
function |
<optional> |
The callback function. Properties
|
||||||||
permissions |
Array.<string> |
A subset of permissions that the caller is allowed. |
Example
const {Bigtable} = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
const instance = bigtable.instance(instanceId);
const table = instance.table(tableId);
const permissions = ['bigtable.tables.get', 'bigtable.tables.readRows'];
table
.testIamPermissions(permissions)
.then(result => {
const grantedPermissions = result[0];
})
.catch(err => {
// Handle the error
});
truncate(gaxOptionsopt, callback)
Truncate the table.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
gaxOptions |
object |
<optional> |
Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html. |
||||||||||||
callback |
function |
The callback function. Properties
|
Example
```
table.truncate(function(err, apiResponse) {});
//-
// If the callback is omitted, we'll return a Promise.
//-
table.truncate().then(function(data) {
const apiResponse = data[0];
});
```
waitForReplication(callback)
Generates Consistency-Token and check consistency for generated token In-case consistency check returns false, retrial is done in interval of 5 seconds till 10 minutes, after that it returns false.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
callback |
function |
The callback function. Properties
|