Class Index

Classes


v1.2.1

DBCatalog

This houses the database catalog information, and is accessible via the DB#catalog property as follows:

var catalog = db.catalog;

Summary
Constructor Attributes Constructor Name and Description
This object houses the database catalog information.
Field Summary
Field Attributes Field Name and Description
The DBFunctionStore catalog of functions available.
Method Summary
Method Attributes Method Name and Description
createTable (tableProperties)
Creates a table with the specified attributes and data.
createTables (tableArray)
A convenience method for creating multiple tables with a single call.
dropTable (tabName)
Drops the specified table from the database catalog.
Returns an array of DBTable objects corresponding to all of the tables in the database's catalog.
Gets the current "persistence scope" of the catalog.
getTable (tableName)
Returns a DBTable object for the specified table.
Returns whether the "persistence scope" is available in the current browser.
setPersistenceScope (newPersistenceScope)
Sets the "persistence scope" of the catalog.
Detail
DBCatalog ()
This object houses the database catalog information.
Field Detail
{ DBFunctionStore } functions
The DBFunctionStore catalog of functions available.
Method Detail
createTable (tableProperties)
Creates a table with the specified attributes and data. Here is an example of creating a table:
	    db.catalog.createTable({
	    	tableName: "EMPL",
	    	columns: [ "EMPL_ID", "NAME", "AGE", "DEPT_ID" ],
	    	primaryKey: [ "EMPL_ID" ],
	    	data: [
	    		[0,"Bob",32,0],
	    		[1,"John",37,2],
	    		[2,"Fred",28,1],
	    		[3,"Sue",26,3],
	    		[4,"Beth",22,99],
	    		[5,"Mary",27,3],
	    		[6,"Adrian",24,1]
	    	]
	    });
	

This action takes part in a transaction, so a DB#commit is required to finalize it, and a DB#rollback will revert the change.

Parameters:
{object} tableProperties
An object containing the properties of the table as follows:

tableName : (required) The name of the table being added.

columns : (required) An array of column names to add to the table.

primaryKey : (optional) An array of the column names that make up the primaryKey.

persistenceScope : (optional) The peristence scope (see DBTable#setPersistenceScope ).

data : (optional) A data array of arrays (rows and columns) to initialize the table's data.

Throws:
{ Exception }
If a table with the same name already exists.
{ Exception }
If data is provided and a row has the incorrect number of columns.
{ Exception }
If primaryKey and data are provided and multiple rows contain the same primary key.

createTables (tableArray)
A convenience method for creating multiple tables with a single call. This method takes an array of table property objects, and calls DBTable.createTable for each one of them.
Parameters:
{object[]} tableArray
An array of tableProperty objects containing the properties of the tables. See DBTable.createTable for the list of valid properties.
Throws:
{ Exception }
If a table with the same name already exists.
{ Exception }
If data is provided and a row has the incorrect number of columns.
{ Exception }
If primaryKey and data are provided and multiple rows contain the same primary key.
See:
DBTable#createTable

dropTable (tabName)
Drops the specified table from the database catalog.

This action takes part in a transaction, so a DB#commit is required to finalize it, and a DB#rollback will revert the change.

Parameters:
{string} tabName
The name of the table to drop.

{ DBTable []} getAllTables ()
Returns an array of DBTable objects corresponding to all of the tables in the database's catalog.
Returns:
{ DBTable []} A DBTable object for the provided tableName , or null if no such table exists.

{const} getPersistenceScope ()
Gets the current "persistence scope" of the catalog. The scope specifies whether the catalog will be stored in memory, in Session, or in a local storage mechanism.
Returns:
{const} The persistence scope of the catalog.
See:
DBCatalog#setPersistenceScope
DBCatalog#isPersistenceScopeAvailable
DBTable#getPersistenceScope

{ DBTable } getTable (tableName)
Returns a DBTable object for the specified table.
Parameters:
{string} tableName
The name of the table being retrieved.
Returns:
{ DBTable } A DBTable object for the provided tableName , or null if no such table exists.

{boolean} isPersistenceScopeAvailable (persistenceScope)
Returns whether the "persistence scope" is available in the current browser. DB.SCOPE_PAGE is available in all browsers. DB.SCOPE_SESSION and DB.SCOPE_LOCAL are available in almost all modern browsers. This method is for informational purposes only, and a call is not required to actually use persistence scopes (when available in the browser).
Parameters:
{const} persistenceScope
The Persistence Scope to test.
Returns:
{boolean} Whether the persistence scope is available in the current browser.
See:
DBCatalog#setPersistenceScope
DBCatalog#getPersistenceScope

setPersistenceScope (newPersistenceScope)
Sets the "persistence scope" of the catalog. This specifies whether the catalog will be stored in memory, in Session, or in a local storage mechanism. This is also used as the default scope for tables set with DB.SCOPE_DEFAULT .

This method takes part in a transaction, so a DB#commit is required to finalize it, and a DB#rollback will revert the change.

Parameters:
{const} newPersistenceScope
The new Persistence Scope
See:
DBCatalog#getPersistenceScope
DBCatalog#isPersistenceScopeAvailable
DBTable#setPersistenceScope
DB#commit

©2012 Sequel Sphere, LLC.