Class: Table

Table

Represents a database table.

Constructor

new Table(table)

Initialize the table using a schema object.
Parameters:
Name Type Description
table Object An object containing a table definition.
Properties
Name Type Attributes Default Description
name string The name of the table.
mapTo string <optional>
table.name When a resource is pulled from this table and serialized, this mapping will be used in the resulting object.
columns Array.<Column> | Array.<object> An array of Columns--or object suitable for the Column constructor--that make up the table. Refer to the Column constructor for property details. At least one of the columns must be a primary key.
foreignKeys Array.<ForeignKey> | Array.<object> An array of ForeignKey instances, or objects suitable for the ForeignKey constructor.
Source:

Members

columns :Array.<Column>

The array of columns.
Type:
Source:

foreignKeys :Array.<ForeignKey>

An array of ForeignKey instances describing the relationship between this table and others.
Type:
Source:

mapTo :string

The property name in the resulting normalized object.
Type:
  • string
Default Value:
  • table.name
Source:

name :string

The name of the column.
Type:
  • string
Source:

primaryKey :Array.<Column>

The table's primary key.
Type:
Source:

Methods

addColumn(column) → {this}

Add a column.
Parameters:
Name Type Description
column Column | object The Column, or a suitable schema object for the Column constructor.
Source:
Returns:
Type
this

getColumnByMapping(mapping) → {Column}

Get a column by mapping (it's mapTo property).
Parameters:
Name Type Description
mapping string The column's mapTo property.
Source:
Returns:
The column instance.
Type
Column

getColumnByName(name) → {Column}

Get a column by name.
Parameters:
Name Type Description
name string The column name.
Source:
Returns:
The Column instance.
Type
Column

isColumnMapping(mapping) → {boolean}

Check if mapping matches a column.
Parameters:
Name Type Description
mapping string The column's mapTo property.
Source:
Returns:
Type
boolean

isColumnName(name) → {boolean}

Check if name matches a column.
Parameters:
Name Type Description
name string The column name.
Source:
Returns:
Type
boolean