new Table(instance, id)

Example

const Bigtable = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
const instance = bigtable.instance('my-instance');
const table = instance.table('prezzy');

Parameters

Name Type Optional Description

instance

 

 

Instance Object.

id

 

 

Unique identifier of the table.

Methods

checkConsistency(token, callback)

Checks consistency for given ConsistencyToken

Parameters

Name Type Optional Description

token

string

 

consistency token

callback

function(nullable error, nullable boolean)

 

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

Error

 

An error returned while making this request.

Value can be null.

consistent

Boolean

 

Boolean value.

Value can be null.

create([options], callback)

Create a table.

Example

include:samples/document-snippets/table.js

region_tag:bigtable_create_table

Parameters

Name Type Optional Description

options

object

Yes

See Instance#createTable.

Values in options have the following properties:

Name Type Optional Description

gaxOptions

object

Yes

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions.

callback

function()

 

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

table

Table

 

The newly created table.

apiResponse

object

 

The full API response.

createFamily(id[, options], 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.

Example

include:samples/document-snippets/table.js

region_tag:bigtable_create_family

Parameters

Name Type Optional Description

id

string

 

The unique identifier of column family.

options

object

Yes

Configuration object.

Values in options have the following properties:

Name Type Optional Description

gaxOptions

object

Yes

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions.

rule

object

Yes

Garbage collection rule

rule.age

object

Yes

Delete cells in a column older than the given age. Values must be at least 1 millisecond.

rule.versions

number

Yes

Maximum number of versions to delete cells in a column, except for the most recent.

rule.intersect

boolean

Yes

Cells to delete should match all rules.

rule.union

boolean

Yes

Cells to delete should match any of the rules.

callback

function()

 

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

family

Family

 

The newly created Family.

apiResponse

object

 

The full API response.

See also

Garbage Collection Proto Docs

Throws

error 

If a name is not provided.

createReadStream([options]) → stream

Get Row objects for the rows currently in your table as a readable object stream.

Example

include:samples/document-snippets/table.js

region_tag:bigtable_table_readstream

Parameters

Name Type Optional Description

options

object

Yes

Configuration object.

Values in options have the following properties:

Name Type Optional Description

decode

boolean

Yes

If set to false it will not decode Buffer values returned from Bigtable.

Defaults to true.

encoding

boolean

Yes

The encoding to use when converting Buffer values to a string.

end

string

Yes

End value for key range.

filter

Filter

Yes

Row filters allow you to both make advanced queries and format how the data is returned.

gaxOptions

object

Yes

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html.

keys

Array of string

Yes

A list of row keys.

limit

number

Yes

Maximum number of rows to be returned.

prefix

string

Yes

Prefix that the row key must match.

prefixes

Array of string

Yes

List of prefixes that a row key must match.

ranges

Array of object

Yes

A list of key ranges.

start

string

Yes

Start value for key range.

Returns

stream 

delete([gaxOptions][, callback])

Delete the table.

Example

include:samples/document-snippets/table.js

region_tag:bigtable_del_table

Parameters

Name Type Optional Description

gaxOptions

object

Yes

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html.

callback

function()

Yes

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

apiResponse

object

 

The full API response.

deleteRows(prefix[, gaxOptions], callback)

Delete all rows in the table, optionally corresponding to a particular prefix.

Example

include:samples/document-snippets/table.js

region_tag:bigtable_del_rows

Parameters

Name Type Optional Description

prefix

string

 

Row key prefix.

gaxOptions

object

Yes

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html.

callback

function()

 

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

apiResponse

object

 

The full API response.

Throws

error 

If a prefix is not provided.

exists([gaxOptions], callback)

Check if a table exists.

Example

include:samples/document-snippets/table.js

region_tag:bigtable_exists_table

Parameters

Name Type Optional Description

gaxOptions

object

Yes

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html.

callback

function()

 

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

exists

boolean

 

Whether the table exists or not.

family(id) → Family

Get a reference to a Table Family.

Example

const family = table.family('my-family');

Parameter

Name Type Optional Description

id

string

 

The family unique identifier.

Throws

error 

If a name is not provided.

Returns

Family 

generateConsistencyToken(callback)

Generates Consistency-Token

Parameters

Name Type Optional Description

callback

function(nullable error, nullable boolean)

 

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

Error

 

An error returned while making this request.

Value can be null.

token

String

 

The generated consistency token.

Value can be null.

get([options])

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.

Example

include:samples/document-snippets/table.js

region_tag:bigtable_get_table

Parameters

Name Type Optional Description

options

object

Yes

Configuration object.

Values in options have the following properties:

Name Type Optional Description

autoCreate

boolean

Yes

Automatically create the instance if it does not already exist.

Defaults to false.

gaxOptions

object

Yes

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html.

callback.error

error

 

An error returned while making this request.

Value can be null.

callback.table

Table

 

The Table object.

callback.apiResponse

object

 

The resource as it exists in the API.

getFamilies([gaxOptions], callback)

Get Family objects for all the column familes in your table.

Example

include:samples/document-snippets/table.js

region_tag:bigtable_get_families

Parameters

Name Type Optional Description

gaxOptions

object

Yes

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html.

callback

function()

 

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

families

Array of Family

 

The list of families.

apiResponse

object

 

The full API response.

getMetadata([options][, callback])

Get the table's metadata.

Example

include:samples/document-snippets/table.js

region_tag:bigtable_get_table_meta

Parameters

Name Type Optional Description

options

object

Yes

Table request options.

Values in options have the following properties:

Name Type Optional Description

gaxOptions

object

Yes

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html.

view

string

Yes

The view to be applied to the table fields.

callback

function()

Yes

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

metadata

object

 

The table's metadata.

getReplicationStates([gaxOptions], callback)

Get replication states of the clusters for this table.

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) {
  var clusterStates = data[0];
  var apiResponse = data[1];
});

Parameters

Name Type Optional Description

gaxOptions

object

Yes

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html.

callback

function()

 

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

clusterStates

Array of Family

 

The map of clusterId and its replication state.

apiResponse

object

 

The full API response.

getRows([options], 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.

Example

include:samples/document-snippets/table.js

region_tag:bigtable_get_rows

Parameters

Name Type Optional Description

options

object

Yes

Configuration object. See Table#createReadStream for a complete list of options.

Values in options have the following properties:

Name Type Optional Description

gaxOptions

object

Yes

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html.

callback

function()

 

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

rows

Array of Row

 

List of Row objects.

insert(entries[, gaxOptions], 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.

Example

include:samples/document-snippets/table.js

region_tag:bigtable_insert_rows

Parameters

Name Type Optional Description

entries

(object or Array of object)

 

List of entries to be inserted. See Table#mutate.

gaxOptions

object

Yes

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html.

callback

function()

 

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

err.errors

Array of object

 

If present, these represent partial failures. It's possible for part of your request to be completed successfully, while the other part was not.

mutate(entries[, options], 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.

Example

include:samples/document-snippets/table.js

region_tag:bigtable_mutate_rows

Parameters

Name Type Optional Description

entries

(object or Array of object)

 

List of entities to be inserted or deleted.

options

object

Yes

Configuration object.

Values in options have the following properties:

Name Type Optional Description

gaxOptions

object

Yes

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions.

rawMutation

boolean

Yes

If set to true will treat entries as a raw Mutation object. See Mutation#parse.

callback

function()

 

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

err.errors

Array of object

 

If present, these represent partial failures. It's possible for part of your request to be completed successfully, while the other part was not.

row(key) → Row

Get a reference to a table row.

Example

var row = table.row('lincoln');

Parameter

Name Type Optional Description

key

string

 

The row key.

Throws

error 

If a key is not provided.

Returns

Row 

sampleRowKeys([gaxOptions][, callback])

Returns a sample of row keys in the table. The returned row keys will delimit contigous sections of the table of approximately equal size, which can be used to break up the data for distributed tasks like mapreduces.

Example

include:samples/document-snippets/table.js

region_tag:bigtable_sample_row_keys

Parameters

Name Type Optional Description

gaxOptions

object

Yes

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html.

callback

function()

Yes

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

keys

Array of object

 

The list of keys.

sampleRowKeysStream([gaxOptions]) → stream

Returns a sample of row keys in the table as a readable object stream.

See Table#sampleRowKeys for more details.

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();
  });

Parameter

Name Type Optional Description

gaxOptions

object

Yes

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html.

Returns

stream 

truncate([gaxOptions], callback)

Truncate the table.

Example

table.truncate(function(err, apiResponse) {});

//-
// If the callback is omitted, we'll return a Promise.
//-
table.truncate().then(function(data) {
  var apiResponse = data[0];
});

Parameters

Name Type Optional Description

gaxOptions

object

Yes

Request configuration options, outlined here: https://googleapis.github.io/gax-nodejs/CallSettings.html.

callback

function()

 

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

apiResponse

object

 

The full API response.

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 Optional Description

callback

function(nullable error, nullable boolean)

 

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

Error

 

An error returned while making this request.

Value can be null.

resp

Boolean

 

Boolean value.

Value can be null.