Constructor

Family

new Family(table, id)

Parameter

table

Table

id

string

Example

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

Methods

create

create(options, callback)

Create a column family.

Parameter

options

Optional

object

See Table#createFamily.

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.

family

Family

The metadata.

apiResponse

object

The full API response.

Examples

const Bigtable = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
const instance = bigtable.instance(instanceId);
const table = instance.table(tableId);
const family = table.family(familyId);

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

delete

delete(gaxOptions, callback)

Delete the column family.

Parameter

gaxOptions

Optional

object

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

callback

Optional

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 Bigtable = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
const instance = bigtable.instance(instanceId);
const table = instance.table(tableId);
const family = table.family(familyId);

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

exists

exists(gaxOptions, callback)

Check if the column family 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 family exists or not.

Examples

const Bigtable = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
const instance = bigtable.instance(instanceId);
const table = instance.table(tableId);
const family = table.family(familyId);

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

get

get(options)

Get a column family if it exists.

You may optionally use this to "get or create" an object by providing an object with autoCreate set to true. Any extra configuration that is normally required for the create method must be contained within this object as well.

Parameter

options

Optional

object

Configuration object.

Values in options have the following properties:

Parameter

autoCreate

Optional

boolean

Automatically create the instance if it does not already exist.

gaxOptions

Optional

object

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

callback.error

error

An error returned while making this request.

Value may be null.

callback.family

Family

The Family object.

callback.apiResponse

object

The resource as it exists in the API.

Examples

const Bigtable = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
const instance = bigtable.instance(instanceId);
const table = instance.table(tableId);
const family = table.family(familyId);

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

getMetadata

getMetadata(gaxOptions, callback)

Get the column family's metadata.

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.

metadata

object

The metadata.

Examples

const Bigtable = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
const instance = bigtable.instance(instanceId);
const table = instance.table(tableId);
const family = table.family(familyId);

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

setMetadata

setMetadata(metadata, gaxOptions, callback)

Set the column family's metadata.

See Table#createFamily for a detailed explanation of the arguments.

Parameter

metadata

object

Metadata object.

Values in metadata have the following properties:

Parameter

rule

Optional

object

Garbage collection rule.

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.

apiResponse

object

The full API response.

See also

Garbage Collection Proto Docs

Examples

const Bigtable = require('@google-cloud/bigtable');
const bigtable = new Bigtable();
const instance = bigtable.instance(instanceId);
const table = instance.table(tableId);
const family = table.family(familyId);

const metadata = {
  rule: {
    versions: 2,
    union: true,
  },
};

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