Constructor

Family

new Family(table, name)

Create a Family object to interact with your table column families.

Parameter

table

Table

name

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');

Property

familyName

string

Methods

create

create(options)

Create a column family.

Parameter

options

Optional

object

See Table#createFamily.

Example

family.create(function(err, family, apiResponse) {
  // The column family was created successfully.
});

//-
// If the callback is omitted, we'll return a Promise.
//-
family.create().then(function(data) {
  const family = data[0];
  const apiResponse = data[1];
});

delete

delete(callback)

Delete the column family.

Parameter

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.

Example

family.delete(function(err, apiResponse) {});

//-
// If the callback is omitted, we'll return a Promise.
//-
family.delete().then(function(data) {
  const apiResponse = data[0];
});

exists

exists(callback)

Check if the column family exists.

Parameter

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.

Example

family.exists(function(err, exists) {});

//-
// If the callback is omitted, we'll return a Promise.
//-
family.exists().then(function(data) {
  const exists = data[0];
});

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 object if it does not exist.

Example

family.get(function(err, family, apiResponse) {
  // `family.metadata` has been populated.
});

//-
// If the callback is omitted, we'll return a Promise.
//-
family.get().then(function(data) {
  const family = data[0];
  const apiResponse = data[1];
});

getMetadata

getMetadata(callback)

Get the column family's metadata.

Parameter

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.

apiResponse

object

The full API response.

Example

family.getMetadata(function(err, metadata, apiResponse) {});

//-
// If the callback is omitted, we'll return a Promise.
//-
family.getMetadata().then(function(data) {
  var metadata = data[0];
  var apiResponse = data[1];
});

setMetadata

setMetadata(metadata, 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.

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

Example

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

family.setMetadata(metadata, function(err, apiResponse) {});

//-
// If the callback is omitted, we'll return a Promise.
//-
family.setMetadata(metadata).then(function(data) {
  var apiResponse = data[0];
});