Constructor

Row

new Row(table, key)

Parameter

table

Table

The row's parent Table instance.

key

string

The key for this row.

Example

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

Methods

create

create(options, callback)

Create a new row in your table.

Parameter

options

Optional

object

Configuration object.

Values in options have the following properties:

Parameter

entry

Optional

object

An entry. See Table#insert.

gaxOptions

Optional

object

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:

Parameter

err

error

An error returned while making this request.

Value may be null.

row

Row

The newly created row object.

apiResponse

object

The full API response.

Examples

const row = table.row('samplerow');

row
  .create()
  .then(result => {
    const apiResponse = result[0];
  })
  .catch(err => {
    // Handle the error.
  });

createRules

createRules(rules, gaxOptions, callback)

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

Parameter

rules

(object or Array of object)

The rules to apply to this row.

gaxOptions

Optional

object

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:

Parameter

err

error

An error returned while making this request.

Value may be null.

apiResponse

object

The full API response.

Throws

error 

If no rules are provided.

Examples

const row = table.row('samplerow');
// -
// Add an increment amount to an existing value, if the targeted cell is
// unset, it will be treated as containing a zero.
//
const rules = [
  {
    column: 'follows:gwashington',
    increment: 1,
  },
];

// -
// You can also create a rule that will append data to an existing value.
// If the targeted cell is unset, it will be treated as a containing an
// empty string.
//
// var rules = [
//   {
//     column: 'follows:alincoln',
//     append: ' Honest Abe!',
//   },
// ];

row
  .createRules(rules)
  .then(result => {
    const apiResponse = result[0];
  })
  .catch(err => {
    // Handle the error.
  });

delete

delete(gaxOptions, callback)

Deletes all cells in the row.

Parameter

gaxOptions

Optional

object

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:

Parameter

err

error

An error returned while making this request.

Value may be null.

apiResponse

object

The full API response.

Examples

const row = table.row('samplerow');
row
  .delete()
  .then(result => {
    const apiResponse = result[0];
  })
  .catch(err => {
    // Handle the error.
  });

deleteCells

deleteCells(columns, gaxOptions, callback)

Delete specified cells from the row. See Table#mutate.

Parameter

columns

Array of string

Column names for the cells to be deleted.

gaxOptions

Optional

object

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:

Parameter

err

error

An error returned while making this request.

Value may be null.

apiResponse

object

The full API response.

Examples

const row = table.row('samplerow');

// Delete selective cell within a family.
// let cells = [
//   'follows:gwashington'
// ];

// Delete all cells within a family.
const cells = ['follows'];

row
  .deleteCells(cells)
  .then(result => {
    const apiResponse = result[0];
  })
  .catch(err => {
    // Handle the error.
  });

exists

exists(gaxOptions, callback)

Check if the table row exists.

Parameter

gaxOptions

Optional

object

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:

Parameter

err

error

An error returned while making this request.

Value may be null.

exists

boolean

Whether the row exists or not.

Examples

const row = table.row('samplerow');

row
  .exists()
  .then(result => {
    const exists = result[0];
  })
  .catch(err => {
    // Handle the error.
  });

filter

filter(filter, config, callback)

Mutates a row atomically based on the output of a filter. Depending on whether or not any results are yielded, either the onMatch or onNoMatch callback will be executed.

Parameter

filter

Filter

Filter to be applied to the contents of the row.

config

object

Configuration object.

Values in config have the following properties:

Parameter

onMatch

Array of object

A list of entries to be ran if a match is found.

Value may be null.

onNoMatch

Optional

Array of object

A list of entries to be ran if no matches are found.

gaxOptions

Optional

object

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:

Parameter

err

error

An error returned while making this request.

Value may be null.

matched

boolean

Whether a match was found or not.

Examples

const row = table.row('samplerow');

const filter = [
  {
    family: 'follows',
  },
  {
    column: 'alincoln',
  },
  {
    value: 1,
  },
];

// Optionally, you can pass in an array of entries to be ran in the event
// that a match is not made.
const config = {
  onNoMatch: [
    {
      method: 'insert',
      data: {
        follows: {
          jadams: 1,
        },
      },
    },
  ],
};

row
  .filter(filter, config)
  .then(result => {
    const matched = result[0];
  })
  .catch(err => {
    // Handle the error.
  });

get

get(columns, options, callback)

Get the row data. See Table#getRows.

Parameter

columns

Optional

Array of string

List of specific columns to retrieve.

options

Optional

object

Configuration object.

Values in options have the following properties:

Parameter

decode

Optional

boolean

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

gaxOptions

Optional

object

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:

Parameter

err

error

An error returned while making this request.

Value may be null.

row

Row

The updated Row object.

Examples

const row = table.row('samplerow');

row
  .get()
  .then(result => {
    const row = result[0];
  })
  .catch(err => {
    // Handle the error.
  });

//-
// Or pass in an array of column names to populate specific cells.
// Under the hood this will create an interleave filter.
//-
// row
//   .get([
//     'follows:gwashington',
//     'follows:alincoln'
//   ])
//   .then(result => {
//     let row = result[0];
//   })
//   .catch(err => {
//     // Handle the error.
//   });

getMetadata

getMetadata(options, callback)

Get the row's metadata.

Parameter

options

Optional

object

Configuration object.

Values in options have the following properties:

Parameter

decode

Optional

boolean

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

gaxOptions

Optional

object

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:

Parameter

err

error

An error returned while making this request.

Value may be null.

metadata

object

The row's metadata.

Examples

const row = table.row('samplerow');

row
  .getMetadata()
  .then(result => {
    const metaData = result[0];
    const apiResponse = result[1];
  })
  .catch(err => {
    // Handle the error.
  });

increment

increment(column, value, gaxOptions, callback)

Increment a specific column within the row. If the column does not exist, it is automatically initialized to 0 before being incremented.

Parameter

column

string

The column we are incrementing a value in.

value

Optional

number

The amount to increment by, defaults to 1.

gaxOptions

Optional

object

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:

Parameter

err

error

An error returned while making this request.

Value may be null.

value

number

The updated value of the column.

apiResponse

object

The full API response.

Examples

const row = table.row('samplerow');

// Specify a custom amount to increment the column by.
// row
//   .increment('follows:gwashington', 2)
//   .then(result => {
//     let value = result[0];
//     let apiResponse = result[1];
// });

// To decrement a column, simply supply a negative value.
// row
//   .increment('follows:gwashington', -1)
//   .then(result => {
//     let value = result[0];
//     let apiResponse = result[1];
// });
row
  .increment('follows:gwashington')
  .then(result => {
    const value = result[0];
    const apiResponse = result[1];
  })
  .catch(err => {
    // Handle the error.
  });

save

save(key, gaxOptions, callback)

Update the row cells.

Parameter

key

object

An entry object to be inserted into the row. See Table#insert.

gaxOptions

Optional

object

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:

Parameter

err

error

An error returned while making this request.

Value may be null.

apiResponse

object

The full API response.

Examples

const row = table.row('samplerow');
const entry = {
  follows: {
    jadams: 1,
  },
};
row
  .save(entry)
  .then(result => {
    const apiResponse = result[0];
  })
  .catch(err => {
    // Handle the error.
  });