Constructor

BigtableClient

new BigtableClient(options)

Construct an instance of BigtableClient.

Parameter

options

Optional

object

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

Values in options have the following properties:

Parameter

credentials

Optional

object

Credentials object.

credentials.client_email

Optional

string

credentials.private_key

Optional

string

email

Optional

string

Account email address. Required when usaing a .pem or .p12 keyFilename.

keyFilename

Optional

string

Full path to the a .json, .pem, or .p12 key downloaded from the Google Developers Console. If you provide a path to a JSON file, the projectId option above is not necessary. NOTE: .pem and .p12 require you to specify options.email as well.

port

Optional

number

The port on which to connect to the remote host.

projectId

Optional

string

The project ID from the Google Developer's Console, e.g. 'grape-spaceship-123'. We will also check the environment variable GCLOUD_PROJECT for your project ID. If your app is running in an environment which supports Application Default Credentials, your project ID will be detected automatically.

promise

Optional

function()

Custom promise module to use instead of native Promises.

servicePath

Optional

string

The domain name of the API remote host.

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.

Values in request have the following properties:

Parameter

tableName

string

The unique name of the table to which the conditional mutation should be applied. Values are of the form projects/<project>/instances/<instance>/tables/<table>.

rowKey

string

The key of the row to which the conditional mutation should be applied.

appProfileId

Optional

string

This is a private alpha release of Cloud Bigtable replication. This feature is not currently available to most Cloud Bigtable customers. This feature might be changed in backward-incompatible ways and is not recommended for production use. It is not subject to any SLA or deprecation policy.

This value specifies routing for replication. If not specified, the "default" application profile will be used.

predicateFilter

Optional

Object

The filter to be applied to the contents of the specified row. Depending on whether or not any results are yielded, either true_mutations or false_mutations will be executed. If unset, checks that the row contains any values at all.

This object should have the same structure as RowFilter

trueMutations

Optional

Array of Object

Changes to be atomically applied to the specified row if predicate_filter yields at least one cell when applied to row_key. Entries are applied in order, meaning that earlier mutations can be masked by later ones. Must contain at least one entry if false_mutations is empty, and at most 100000.

This object should have the same structure as Mutation

falseMutations

Optional

Array of Object

Changes to be atomically applied to the specified row if predicate_filter does not yield any cells when applied to row_key. Entries are applied in order, meaning that earlier mutations can be masked by later ones. Must contain at least one entry if true_mutations is empty, and at most 100000.

This object should have the same structure as Mutation

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.

Values in request have the following properties:

Parameter

tableName

string

The unique name of the table to which the mutation should be applied. Values are of the form projects/<project>/instances/<instance>/tables/<table>.

rowKey

string

The key of the row to which the mutation should be applied.

mutations

Array of Object

Changes to be atomically applied to the specified row. Entries are applied in order, meaning that earlier mutations can be masked by later ones. Must contain at least one entry and at most 100000.

This object should have the same structure as Mutation

appProfileId

Optional

string

This is a private alpha release of Cloud Bigtable replication. This feature is not currently available to most Cloud Bigtable customers. This feature might be changed in backward-incompatible ways and is not recommended for production use. It is not subject to any SLA or deprecation policy.

This value specifies routing for replication. If not specified, the "default" application profile will be used.

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.

Values in request have the following properties:

Parameter

tableName

string

The unique name of the table to which the mutations should be applied.

entries

Array of Object

The row keys and corresponding mutations to be applied in bulk. Each entry is applied as an atomic mutation, but the entries may be applied in arbitrary order (even between entries for the same row). At least one entry must be specified, and in total the entries can contain at most 100000 mutations.

This object should have the same structure as Entry

appProfileId

Optional

string

This is a private alpha release of Cloud Bigtable replication. This feature is not currently available to most Cloud Bigtable customers. This feature might be changed in backward-incompatible ways and is not recommended for production use. It is not subject to any SLA or deprecation policy.

This value specifies routing for replication. If not specified, the "default" application profile will be used.

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.

Values in request have the following properties:

Parameter

tableName

string

The unique name of the table to which the read/modify/write rules should be applied. Values are of the form projects/<project>/instances/<instance>/tables/<table>.

rowKey

string

The key of the row to which the read/modify/write rules should be applied.

rules

Array of Object

Rules specifying how the specified row's contents are to be transformed into writes. Entries are applied in order, meaning that earlier rules will affect the results of later ones.

This object should have the same structure as ReadModifyWriteRule

appProfileId

Optional

string

This is a private alpha release of Cloud Bigtable replication. This feature is not currently available to most Cloud Bigtable customers. This feature might be changed in backward-incompatible ways and is not recommended for production use. It is not subject to any SLA or deprecation policy.

This value specifies routing for replication. If not specified, the "default" application profile will be used.

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.

Values in request have the following properties:

Parameter

tableName

string

The unique name of the table from which to read. Values are of the form projects/<project>/instances/<instance>/tables/<table>.

appProfileId

Optional

string

This is a private alpha release of Cloud Bigtable replication. This feature is not currently available to most Cloud Bigtable customers. This feature might be changed in backward-incompatible ways and is not recommended for production use. It is not subject to any SLA or deprecation policy.

This value specifies routing for replication. If not specified, the "default" application profile will be used.

rows

Optional

Object

The row keys and/or ranges to read. If not specified, reads from all rows.

This object should have the same structure as RowSet

filter

Optional

Object

The filter to apply to the contents of the specified row(s). If unset, reads the entirety of each row.

This object should have the same structure as RowFilter

rowsLimit

Optional

number

The read will terminate after committing to N rows' worth of results. The default (zero) is to return all results.

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.

Values in request have the following properties:

Parameter

tableName

string

The unique name of the table from which to sample row keys. Values are of the form projects/<project>/instances/<instance>/tables/<table>.

appProfileId

Optional

string

This is a private alpha release of Cloud Bigtable replication. This feature is not currently available to most Cloud Bigtable customers. This feature might be changed in backward-incompatible ways and is not recommended for production use. It is not subject to any SLA or deprecation policy.

This value specifies routing for replication. If not specified, the "default" application profile will be used.

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