Select2Object

Select2Object

  • Executes a SELECT statement on sheet data. Returned data will be any array of objects, where each item is one row of data. The property values in the object are the column names. The column names will be in lower case. If more than one table is referenced, the column name will be: "table.column", otherwise it will just be the column name. Spaces in the column name use the underscore, so something like "Transaction Date" would be referenced as "transaction_date".

Constructor

new Select2Object()

Source:

Methods

addBindVariable(bindVar) → {Select2Object}

Description:
  • If bind variables are used in SELECT statement, this are added here. Ordering is important. The first one added will be '?1' in the select, second is '?2' in select...

Source:
Parameters:
Name Type Description
bindVar any
Returns:
Type
Select2Object

addTableData(tableName, data) → {Select2Object}

Source:
Parameters:
Name Type Description
tableName String

table name referenced in SELECT statement.

data *

double array or string. If string it must reference A1 notation, named range or sheet name.

Returns:
Type
Select2Object

execute(statement) → {Array.<Object>}

Description:
  • Query any sheet range using standard SQL SELECT syntax and return array of table info with column names as properties.

Source:
Example
gsSQL("select * from expenses where type = ?1")
Parameters:
Name Type Description
statement String

SQL string

Returns:
  • array of object data.
Type
Array.<Object>

selectToClass(className) → {Select2Object}

Description:
  • When creating the object to be returned, rather than assign from an empty object '{}', a new instance of this class is created instead.

Source:
Parameters:
Name Type Description
className Object
Returns:
Type
Select2Object

(static) cleanupColumnNames(cols) → {Array.<String>}

Description:
  • Return column names in lower case and remove table name when only one table.

Source:
Parameters:
Name Type Description
cols Array.<String>
Returns:
Type
Array.<String>

(static) convertColumnTitleToPropertyName(columnTitles) → {Array.<String>}

Description:
  • Convert a sheet column name into format used for property name (spaces to underscore && lowercase)

Source:
Parameters:
Name Type Description
columnTitles Array.<String>
Returns:
Type
Array.<String>

(static) convertObjectArrayToTableArray(objectArray, columnTitles, outputTitleRow) → {Array.<Array.<any>>}

Source:
Parameters:
Name Type Default Description
objectArray Array.<Object>
columnTitles Array.<String>
outputTitleRow Boolean true
Returns:
Type
Array.<Array.<any>>

(static) convertObjectToArray(object, columnTitles) → {Array.<String>}

Source:
Parameters:
Name Type Description
object Object
columnTitles Array.<String>
Returns:
Type
Array.<String>

(static) convertTableArrayToObjectArray(tableDataArray) → {Array.<Object>}

Description:
  • First row MUST be column names.

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

(static) createEmptyRecordObject(columnNames) → {Object}

Description:
  • Creates an empty object where each column name is a property in the object.

Source:
Parameters:
Name Type Description
columnNames Array.<String>
Returns:
Type
Object

(static) createTableObjectArray(columnNames, tableDataArray, SelectClass) → {Array.<Object>}

Source:
Parameters:
Name Type Default Description
columnNames Array.<String>
tableDataArray Array.<any>
SelectClass Object null
Returns:
Type
Array.<Object>

(static) getColumnNumber(object, columnTitle) → {Number}

Description:
  • Get column number - starting at 1 in object.

Source:
Parameters:
Name Type Description
object Object
columnTitle String
Returns:
Type
Number