Constructor

BigtableClient

new BigtableClient(options)

Construct an instance of BigtableClient.

Parameter

options

Optional

object

The configuration object. See the subsequent parameters for more details.

Properties

port

static

The port for this API service.

scopes

static

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

static

The DNS address for this API service.

Methods

checkAndMutateRow

checkAndMutateRow(request, options, callback) returns Promise

Mutates a row atomically based on the output of a predicate Reader filter.

Parameter

request

Object

The request object that will be sent.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing CheckAndMutateRowResponse.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing CheckAndMutateRowResponse. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const bigtable = require('@google-cloud/bigtable');

var client = new bigtable.v2.BigtableClient({
  // optional auth parameters.
});

var formattedTableName = client.tablePath('[PROJECT]', '[INSTANCE]', '[TABLE]');
var rowKey = '';
var request = {
  tableName: formattedTableName,
  rowKey: rowKey,
};
client.checkAndMutateRow(request)
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getProjectId

getProjectId(callback)

Return the project ID used by this class.

Parameter

callback

function(Error, string)

the callback to be called with the current project Id.

matchInstanceFromTableName

matchInstanceFromTableName(tableName) returns String

Parse the tableName from a table resource.

Parameter

tableName

String

A fully-qualified path representing a table resources.

Returns

String 

  • A string representing the instance.

matchProjectFromTableName

matchProjectFromTableName(tableName) returns String

Parse the tableName from a table resource.

Parameter

tableName

String

A fully-qualified path representing a table resources.

Returns

String 

  • A string representing the project.

matchTableFromTableName

matchTableFromTableName(tableName) returns String

Parse the tableName from a table resource.

Parameter

tableName

String

A fully-qualified path representing a table resources.

Returns

String 

  • A string representing the table.

mutateRow

mutateRow(request, options, callback) returns Promise

Mutates a row atomically. Cells already present in the row are left unchanged unless explicitly changed by mutation.

Parameter

request

Object

The request object that will be sent.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing MutateRowResponse.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing MutateRowResponse. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const bigtable = require('@google-cloud/bigtable');

var client = new bigtable.v2.BigtableClient({
  // optional auth parameters.
});

var formattedTableName = client.tablePath('[PROJECT]', '[INSTANCE]', '[TABLE]');
var rowKey = '';
var mutations = [];
var request = {
  tableName: formattedTableName,
  rowKey: rowKey,
  mutations: mutations,
};
client.mutateRow(request)
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

mutateRows

mutateRows(request, options) returns Stream

Mutates multiple rows in a batch. Each individual row is mutated atomically as in MutateRow, but the entire batch is not executed atomically.

Parameter

request

Object

The request object that will be sent.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

Returns

Stream 

An object stream which emits MutateRowsResponse on 'data' event.

Example

const bigtable = require('@google-cloud/bigtable');

var client = new bigtable.v2.BigtableClient({
  // optional auth parameters.
});

var formattedTableName = client.tablePath('[PROJECT]', '[INSTANCE]', '[TABLE]');
var entries = [];
var request = {
  tableName: formattedTableName,
  entries: entries,
};
client.mutateRows(request).on('data', response => {
  // doThingsWith(response)
});

readModifyWriteRow

readModifyWriteRow(request, options, callback) returns Promise

Modifies a row atomically on the server. The method reads the latest existing timestamp and value from the specified columns and writes a new entry based on pre-defined read/modify/write rules. The new value for the timestamp is the greater of the existing timestamp or the current server time. The method returns the new contents of all modified cells.

Parameter

request

Object

The request object that will be sent.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing ReadModifyWriteRowResponse.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing ReadModifyWriteRowResponse. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const bigtable = require('@google-cloud/bigtable');

var client = new bigtable.v2.BigtableClient({
  // optional auth parameters.
});

var formattedTableName = client.tablePath('[PROJECT]', '[INSTANCE]', '[TABLE]');
var rowKey = '';
var rules = [];
var request = {
  tableName: formattedTableName,
  rowKey: rowKey,
  rules: rules,
};
client.readModifyWriteRow(request)
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

readRows

readRows(request, options) returns Stream

Streams back the contents of all requested rows in key order, optionally applying the same Reader filter to each. Depending on their size, rows and cells may be broken up across multiple responses, but atomicity of each row will still be preserved. See the ReadRowsResponse documentation for details.

Parameter

request

Object

The request object that will be sent.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

Returns

Stream 

An object stream which emits ReadRowsResponse on 'data' event.

Example

const bigtable = require('@google-cloud/bigtable');

var client = new bigtable.v2.BigtableClient({
  // optional auth parameters.
});

var formattedTableName = client.tablePath('[PROJECT]', '[INSTANCE]', '[TABLE]');
client.readRows({tableName: formattedTableName}).on('data', response => {
  // doThingsWith(response)
});

sampleRowKeys

sampleRowKeys(request, options) returns Stream

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.

Parameter

request

Object

The request object that will be sent.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

Returns

Stream 

An object stream which emits SampleRowKeysResponse on 'data' event.

Example

const bigtable = require('@google-cloud/bigtable');

var client = new bigtable.v2.BigtableClient({
  // optional auth parameters.
});

var formattedTableName = client.tablePath('[PROJECT]', '[INSTANCE]', '[TABLE]');
client.sampleRowKeys({tableName: formattedTableName}).on('data', response => {
  // doThingsWith(response)
});

tablePath

tablePath(project, instance, table) returns String

Return a fully-qualified table resource name string.

Parameter

project

String

instance

String

table

String

Returns

String