Class: TableMetaList

TableMetaList

A helper class for keeping meta data about a list of tables.

Constructor

new TableMetaList(database)

Initialize the list.
Parameters:
Name Type Description
database Database A Database instance, for which table metadata will be stored.
Source:

Members

availableCols :Map.<TableMetaList~ColumnMeta>

This is a map of all the available columns, indexed by fully-qualified column name. These are the columns that are available for selecting, performing conditions on, or ordering by.
Type:
Source:

database :Database

The database instance, for which table metadata will be stored.
Type:
Source:

mapHierarchy :Map.<Set.<string>>

This holds the mapping (mapTo) hierarchy. The map uses the parent alias as the key (for top-level tables the parent key is literally null), and a Set of mapping names (mapTo) as the values. The same mapping can be used multiple times, but each mapping must be unique to a parent. For example, it's valid for a person to have a "photo" and a building to have a "photo," but there cannot be two "photo" properties at the top level, nor under person.
Type:
  • Map.<Set.<string>>
Source:

tableMetas :Map.<TableMetaList~TableMeta>

The map of TableMetaList~TableMeta objects. The key is the table's unique alias.
Type:
Source:

Methods

addTable(meta) → {this}

Add a table to the list, and make all the columns in the table "available" for use in a select, condition, or order clause.
Parameters:
Name Type Description
meta TableMetaList~TableMeta A meta object describing the table.
Source:
Returns:
Type
this

isColumnAvailable(fqColName) → {boolean}

Check if the columns is available (for selecting, for a condition, or for an order by clause).
Parameters:
Name Type Description
fqColName string The fully-qualified column name to look for.
Source:
Returns:
true if the column is available, false otherwise.
Type
boolean

Type Definitions

ColumnMeta

Type:
  • Object
Properties:
Name Type Description
tableAlias string The unique alias of the table to which the column belongs.
column Column The Column instance.
fqColName string The fully-qualified column name, in the form <table-alias>.<column-name>.
Source:

TableMeta

Type:
  • Object
Properties:
Name Type Attributes Default Description
table string The name of the table, or a Table instance.
as string <optional>
Table.name An alias for the table. This is needed if, for example, the same table is joined in multiple times. If not provided the alias defaults to the table name.
mapTo string <optional>
Table.mapTo The table mapping. That is, the name of the property in the resulting normalised object.
cond Condition <optional>
null The condition (WHERE or ON) associated with the table.
parent string <optional>
null The alias of the parent table, if any.
relType Schema.RELATIONSHIP_TYPE <optional>
Schema~RELATIONSHIP_TYPE.MANY The type of relationship between the parent and this table ("single" or "many"). If set to "single" the table will be serialized into an object, otherwise the table will be serialized into an array. "many" is the default.
joinType From.JOIN_TYPE <optional>
null The type of join, if any. Leave null for the FROM table.
Source: