TabularApiSurface

TabularApiSurface

The TabularApiSurface class is a class that contains methods we want to expose on both tables and authorized views. It also contains data that will be used by both Authorized views and Tables for these shared methods.

Constructor

new TabularApiSurface(instance, id)

Parameters:
Name Type Description
instance Instance

Instance Object.

id string

Unique identifier of the table.

Methods

createReadStream(optionsopt) → {stream}

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

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.

encoding boolean <optional>

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

end string <optional>

End value for key range.

filter Filter <optional>

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

gaxOptions object <optional>

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

keys Array.<string> <optional>

A list of row keys.

limit number <optional>

Maximum number of rows to be returned.

prefix string <optional>

Prefix that the row key must match.

prefixes Array.<string> <optional>

List of prefixes that a row key must match.

ranges Array.<object> <optional>

A list of key ranges.

start string <optional>

Start value for key range.

Returns:
Type Description
stream
Example
    table
      .createReadStream()
      .on('error', err => {
        // Handle the error.
      })
      .on('data', row => {
        // `row` is a Row object.
      })
      .on('end', () => {
        // All rows retrieved.
      });
    //-
    // If you anticipate many results, you can end a stream early to prevent
    // unnecessary processing.
    //-
    // table
    //   .createReadStream()
    //   .on('data', function (row) {
    //     this.end();
    //   });

    //-
    // Specify arbitrary keys for a non-contiguous set of rows.
    // The total size of the keys must remain under 1MB, after encoding.
    //-
    // table.createReadStream({
    //   keys: [
    //     'alincoln',
    //     'gwashington'
    //   ]
    // });

    //-
    // Scan for row keys that contain a specific prefix.
    //-
    // table.createReadStream({
    //   prefix: 'gwash'
    // });

    //-
    // Specify a contiguous range of rows to read by supplying `start` and `end`
    // keys.
    //
    // If the `start` key is omitted, it is interpreted as an empty string.
    // If the `end` key is omitted, it is interpreted as infinity.
    //-
    // table.createReadStream({
    //   start: 'alincoln',
    //   end: 'gwashington'
    // });

    //-
    // Specify multiple ranges.
    //-
    // table.createReadStream({
    //   ranges: [{
    //     start: 'alincoln',
    //     end: 'gwashington'
    //   }, {
    //     start: 'tjefferson',
    //     end: 'jadams'
    //   }]
    // });

    //-
    // Apply a Filter to the contents of the specified rows.
    //-
    // table.createReadStream({
    //   filter: [
    //     {
    //       column: 'gwashington'
    //     }, {
    //       value: 1
    //     }
    //   ]
    // });
    //

getRows(optionsopt, 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.

Parameters:
Name Type Attributes Description
options object <optional>

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

Properties
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.

rows Array.<Row>

List of Row objects.

Example
    const options = {
      keys: ['alincoln', 'gwashington'],
    };
    table
      .getRows(options)
      .then(result => {
        const rows = result[0];
      })
      .catch(err => {
        // Handle the error.
      });

insert(entries, gaxOptionsopt, 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.

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

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

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.

Properties
Name Type Description
errors Array.<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.

Example
    const entries = [
      {
        key: 'alincoln',
        data: {
          follows: {
            gwashington: 1,
          },
        },
      },
    ];

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

mutate(entries, optionsopt, 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.

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

List of entities to be inserted or deleted.

options object <optional>

Configuration object.

Properties
Name Type Attributes Description
gaxOptions object <optional>

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

rawMutation boolean <optional>

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

callback function

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

Properties
Name Type Description
errors Array.<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.

Example
    const entries = [
      {
        method: 'delete',
        key: 'alincoln',
      },
    ];
    table
      .mutate(entries)
      .then(() => {
        // handle success
      })
      .catch(err => {
        // Handle the error.
      });

row(key) → {Row}

Get a reference to a table row.

Parameters:
Name Type Description
key string

The row key.

Returns:
Type Description
Row
Throws:

If a key is not provided.

Type
error
Example
```
const row = table.row('lincoln');
```

sampleRowKeys(gaxOptionsopt, callbackopt)

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.

Parameters:
Name Type Attributes Description
gaxOptions object <optional>

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

callback function <optional>

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

keys Array.<object>

The list of keys.

Example
    table
      .sampleRowKeys()
      .then(result => {
        const sampleRKeys = result[0];
      })
      .catch(err => {
        // Handle the error.
      });

sampleRowKeysStream(gaxOptionsopt) → {stream}

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

See Table#sampleRowKeys for more details.

Parameters:
Name Type Attributes Description
gaxOptions object <optional>

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

Returns:
Type Description
stream
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();
  });
```