Skip to content

jSQLTable class

Pamblam edited this page Dec 11, 2016 · 2 revisions

This class represents a table in the database. The database is located in jSQL.tables and is an object whose keys are table names and values are their respective jSQLTable classes.

These tables are altered and queried by jSQLQuery objects, but may be interacted with directly if desired.

Back to Top


jSQLTable.name

The name of the table. (string)

Back to Top


jSQLTable.columns

An array of the table's column names.

Back to Top


jSQLTable.data

A 2D array of the table's data.

Back to Top


jSQLTable.colmap

An object whos keys are column names and values are their respective array index.

Back to Top


jSQLTable.renameColumn(oldname, newname)

Renames a column in the table.

Parameters
  • oldname: The name of the column to be changed. (string)
  • newname: The new name of the column. (string)
Example
jSQL.tables.Users.renameColumn('Name', 'FullName');
jSQL.persist();

Back to Top


jSQLTable.addColumn(name, defaultVal)

Adds a column to a table.

Parameters
  • name: The name of the column to be added. (string)
  • newname: The default value for this column. All existing rows will be assigned this value.
Example
jSQL.tables.Users.addColumn('FavoriteColor', 'Green');
jSQL.persist();

Back to Top


jSQLTable.loadData(data)

Adds multiple rows to a table.

Parameters
  • data: A 2D array of data to be added to the table.
Example
var data = [
    {Name: "Delux Model", "ProductID": 0},
    {Name: "Supreme Model", "ProductID": 1},
    {Name: "Super Model", "ProductID": 2},
    {Name: "Regular Model", "ProductID": 3},
    {Name: "Small Model", "ProductID": 4}
];
jSQL.tables.Products.loadData(data);
jSQL.persist();

Back to Top


jSQLTable.insertRow(data)

Adds a row to a table.

Parameters
  • data: An array of data to be added to the table.
Example
var data = ["Sooper Delux Model", 5];
jSQL.tables.Products.insertRow(data);
jSQL.persist();

Back to Top


Clone this wiki locally