DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY (EXCEPT INSIDE THE DIV BELOW WITH ID=DESCRIPTION), UNLESS YOU KNOW WHAT YOU'RE DOING.
THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO AUTO UPDATE THE CONTENT THROUGH THE DOC GENERATOR.
Enter additional information related to this 'class' inside the {div} macro with 'id=description'
{column:width=80px|padding=0px}{column}{column}{column}
Method Summary
createNewTable(tableName)
Creates in this server a new table with the specified name.
getTable(tableName)
Returns a JSTable instance corresponding to the table with the specified name from this server.
String[]
getTableNames()
Returns an array with the names of all tables in this server.
void
reloadDataModel()
Reloads the datamodel from the database, if changed externally or via rawSQL plugin.
synchronizeWithDB(table)
Synchronizes a JSTable instance with the database.
{column:width=100%|padding=0px}{column}
Method Details
createNewTable
(tableName)
Parameters
{String} tableName – The name of the table to create.
Sample
var server = plugins.maintenance.getServer("example_data"); if (server) { var table = server.createNewTable("new_table"); if (table) { var pk = table.createNewColumn("new_table_id", JSColumn.INTEGER, 0); pk.rowIdentifierType = JSColumn.PK_COLUMN; if (server.synchronizeWithDB(table)) application.output("New table created in the database."); else application.output("New table not created in database."); } else application.output("New table not created at all."); }
dropTable
(tableName)
Parameters
{String} tableName – The name of the table to drop.
Sample
var server = plugins.maintenance.getServer("example_data"); if (server) { var result = server.dropTable("new_table"); if (result) application.output("Table dropped."); else application.output("Table not dropped."); }
getTable
(tableName)
Parameters
{String} tableName – The name of the table to retrieve.
Sample
var server = plugins.maintenance.getServer("example_data"); if (server) { var table = server.getTable("employees"); if (table) { var colNames = table.getColumnNames() application.output("Table has " + colNames.length + " columns."); for (var i=0; i<colNames.length; i++) application.output("Column " + i + ": " + colNames[i]); } }
String[]
getTableNames
()
Sample
var server = plugins.maintenance.getServer("example_data"); if (server) { var tableNames = server.getTableNames(); application.output("There are " + tableNames.length + " tables."); for (var i=0; i<tableNames.length; i++) application.output("Table " + i + ": " + tableNames[i]); } else { plugins.dialogs.showInfoDialog("Attention","Server 'example_data' cannot be found.","OK"); }
isValid
()
Sample
var server = plugins.maintenance.getServer("example_data"); if (!server.isValid()) { application.output("Server not valid!"); }
void
reloadDataModel
()
Returns
void
Sample
var server = plugins.maintenance.getServer("example_data"); var result = plugins.rawSQL.executeSQL("example_data", null, 'CREATE TABLE raw_table (raw_table_id INTEGER)'); if (result) { application.output("Table created through rawSQL plugin."); if (server) { server.reloadDataModel(); // All existing JSTableObject/JSColumn object references are invalid now! Use getTable to get new ones. var table = server.getTable("raw_table"); if (table) { var colNames = table.getColumnNames() application.output("Table has " + colNames.length + " columns."); for (var i=0; i<colNames.length; i++) application.output("Column " + i + ": " + colNames[i]); } } } else { application.output("Raw table creation failed: " + plugins.rawSQL.getException()); }
synchronizeWithDB
(table)
Parameters
{JSTableObject} table – A JSTableObject instance that should be synchronized.
Sample
var server = plugins.maintenance.getServer("example_data"); if (server) { var table = server.createNewTable("new_table"); if (table) { var pk = table.createNewColumn("new_table_id", JSColumn.INTEGER, 0); pk.rowIdentifierType = JSColumn.PK_COLUMN; if (server.synchronizeWithDB(table)) application.output("New table created in the database."); else application.output("New table not created in database."); } else application.output("New table not created at all."); }