Row

Row

Create a Row object to interact with your table rows.

Constructor

new Row(table, key)

Parameters:
Name Type Description
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(optionsopt, callback)

Create a new row in your table.

Parameters:
Name Type Attributes Description
options object <optional>

Configuration object.

Properties
Name Type Attributes Description
entry object <optional>

An entry. See Table#insert.

gaxOptions object <optional>

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

callback function

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

row Row

The newly created row object.

apiResponse object

The full API response.

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

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

createRules(rules, gaxOptionsopt, 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.

Parameters:
Name Type Attributes Description
rules object | Array.<object>

The rules to apply to this row.

gaxOptions object <optional>

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

callback function

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

apiResponse object

The full API response.

Throws:

If no rules are provided.

Type
error
Example
    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.
    //
    // const rules = [
    //   {
    //     column: 'follows:alincoln',
    //     append: ' Honest Abe!',
    //   },
    // ];

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

delete(gaxOptionsopt, callback)

Deletes all cells in the row.

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
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

apiResponse object

The full API response.

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

deleteCells(columns, gaxOptionsopt, callback)

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

Parameters:
Name Type Attributes Description
columns Array.<string>

Column names for the cells to be deleted.

gaxOptions object <optional>

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

callback function

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

apiResponse object

The full API response.

Example
    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(gaxOptionsopt, callback)

Check if the table row 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
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

exists boolean

Whether the row exists or not.

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

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

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.

Parameters:
Name Type Description
filter Filter

Filter to be applied to the contents of the row.

config object

Configuration object.

Properties
Name Type Attributes Description
onMatch Array.<object> <nullable>

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

onNoMatch Array.<object> <optional>

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

gaxOptions object <optional>

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

callback function

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

matched boolean

Whether a match was found or not.

Example
    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(columnsopt, optionsopt, callback)

Get the row data. See Table#getRows.

Parameters:
Name Type Attributes Description
columns Array.<string> <optional>

List of specific columns to retrieve.

options object <optional>

Configuration object.

Properties
Name Type Attributes Default Description
decode boolean <optional>
true

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

gaxOptions object <optional>

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

callback function

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

row Row

The updated Row object.

Example
    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(optionsopt, callback)

Get the row's metadata.

Parameters:
Name Type Attributes Description
options object <optional>

Configuration object.

Properties
Name Type Attributes Default Description
decode boolean <optional>
true

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

gaxOptions object <optional>

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

callback function

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

metadata object

The row's metadata.

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

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

increment(column, valueopt, gaxOptionsopt, callback)

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

Parameters:
Name Type Attributes Description
column string

The column we are incrementing a value in.

value number <optional>

The amount to increment by, defaults to 1.

gaxOptions object <optional>

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

callback function

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

value number

The updated value of the column.

apiResponse object

The full API response.

Example
    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(key, gaxOptionsopt, callback)

Update the row cells.

Parameters:
Name Type Attributes Description
key object

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

gaxOptions object <optional>

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

callback function

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

apiResponse object

The full API response.

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