Table

Table

Data and methods for each (logical) SQL table.

Constructor

new Table(tableName)

Source:
Parameters:
Name Type Description
tableName String

name of sql table.

Members

hasColumnTitle

Source:
Properties:
Type Description
Boolean

schema

Source:
Properties:
Type Description
Schema

tableData

Source:
Properties:
Type Description
Array.<Array.<any>>

table data.

tableName

Source:
Properties:
Type Description
String

table name.

Methods

addColumnLetters(tableData) → {Array.<Array.<any>>}

Description:
  • Internal function for updating the loaded data to include column names using letters, starting from 'A', 'B',...

Source:
Parameters:
Name Type Description
tableData Array.<Array.<any>>

table data that does not currently contain a first row with column names.

Returns:
  • updated table data that includes a column title row.
Type
Array.<Array.<any>>

concat(concatTable) → {void}

Description:
  • Append table data from 'concatTable' to the end of this tables existing data.

Source:
Parameters:
Name Type Description
concatTable Table

Append 'concatTable' data to end of current table data.

Returns:
Type
void

createCalcFieldRecordMap(calcSqlField, calcField) → {Map.<String, Array.<Number>>}

Description:
  • The calculated field is evaluated for every record in the table. Each unique calculated value will map to a list of table record numbers where the calculated value will be found.

Source:
Parameters:
Name Type Description
calcSqlField CalculatedField
calcField String
Returns:
Type
Map.<String, Array.<Number>>

createKeyFieldRecordMap(fieldName, calcSqlField, calcField) → {Map.<String, Array.<Number>>}

Description:
  • Create a logical table index on input field name. The resulting map is stored with the table. The Map<fieldDataItem, [rowNumbers]> is stored.

Source:
Parameters:
Name Type Default Description
fieldName String

field name to index.

calcSqlField CalculatedField null
calcField String
Returns:
Type
Map.<String, Array.<Number>>

getAllExtendedNotationFieldNames() → {Array.<String>}

Description:
  • Returns table field names that are prefixed with table name.

Source:
Returns:
  • field names
Type
Array.<String>

getAllFieldNames() → {Array.<String>}

Description:
  • Returns a list of all possible field names that could be used in the SELECT.

Source:
Returns:
  • List of field names.
Type
Array.<String>

getAllVirtualFields() → {Array.<VirtualField>}

Description:
  • Find all field data for this table (or the derived table)

Source:
Returns:
  • field column information list
Type
Array.<VirtualField>

getColumnCount() → {Number}

Description:
  • Find number of columns in table.

Source:
Returns:
  • column count.
Type
Number

getFieldColumn(fieldName) → {Number}

Description:
  • Find column number using the field name.

Source:
Parameters:
Name Type Description
fieldName String

Valid field name.

Returns:
  • column offset number starting at zero.
Type
Number

getFieldColumns(fieldNames) → {Array.<Number>}

Description:
  • Get field column index (starts at 0) for field names.

Source:
Parameters:
Name Type Description
fieldNames Array.<String>

list of valid field names.

Returns:
  • list of column offsets, starting at zero corresponding to the input list of names.
Type
Array.<Number>

getRecords(startRecord, lastRecord, fields) → {Array.<Array.<any>>}

Description:
  • Return range of records from table.

Source:
Parameters:
Name Type Description
startRecord Number

1 is first record

lastRecord Number

-1 for all. Last = RecordCount().

fields Array.<Number>

fields to include in output

Returns:
  • subset table data.
Type
Array.<Array.<any>>

loadArrayData(tableData) → {Table}

Description:
  • Read table data from a double array rather than from sheets.

Source:
Parameters:
Name Type Description
tableData Array.<any>

Loaded table data with first row titles included.

Returns:
Type
Table

loadNamedRangeData(namedRange, cacheSeconds) → {Table}

Description:
  • Load sheets named range of data into table.

Source:
Parameters:
Name Type Default Description
namedRange String

defines where data is located in sheets.

  • sheet name - reads entire sheet from top left corner.
  • named range - reads named range for data.
  • A1 notation - range of data using normal sheets notation like 'A1:C10'. This may also include the sheet name like 'stocks!A1:C100'.
cacheSeconds Number 0

How many seconds to cache data so we don't need to make time consuming getValues() from sheets.

Returns:
Type
Table

loadSchema() → {Table}

Description:
  • Read loaded table data and updates internal list of column information

Source:
Returns:
Type
Table

numberToSheetColumnLetter(number) → {String}

Description:
  • Find the sheet column letter name based on position.

Source:
Parameters:
Name Type Description
number Number

Returns the sheets column name.
1 = 'A' 2 = 'B' 26 = 'Z' 27 = 'AA'

Returns:
  • the column letter.
Type
String

setHasColumnTitle(hasTitle) → {Table}

Description:
  • Indicate if data contains a column title row.

Source:
Parameters:
Name Type Description
hasTitle Boolean
  • true - first row of data will contain unique column names
  • false - first row of data will contain data. Column names are then referenced as letters (A, B, ...)
Returns:
Type
Table

setTableAlias(tableAlias) → {Table}

Description:
  • Set associated table alias name to object.

Source:
Parameters:
Name Type Description
tableAlias String

table alias that may be used to prefix column names.

Returns:
Type
Table

(static) removeEmptyRecordsAtEndOfTable(tableData) → {Array.<Array.<any>>}

Description:
  • It is common to have extra empty records loaded at end of table. Remove those empty records at END of table only.

Source:
Parameters:
Name Type Description
tableData Array.<Array.<any>>
Returns:
Type
Array.<Array.<any>>