DatabaseConnector
Module | ejs.db |
Definition | class DatabaseConnector |
Specified | ejscript-2.5 |
Stability | Evolving. |
Database Connector interface.
The database connector interface is the contract implemented by concrete database implementations. This interface is implemented by database connectors such as SQLite and MYSQL.
Properties
(No own properties defined)
DatabaseConnector Class Methods
Qualifiers | Method |
---|
DatabaseConnector Instance Methods
Qualifiers | Method |
---|---|
addColumn(table: String, column: String, datatype: String, options: Object): Void | |
Add a column to a table. | |
addIndex(table: String, column: String, index: String): Void | |
Add an index on a column.P. | |
changeColumn(table: String, column: String, datatype: String, options: Object): Void | |
Change a column. | |
close(): Void | |
Close the database connection. | |
createDatabase(name: String, options: Object): Void | |
Create a new database. | |
createTable(table: String, columns: Array): Void | |
Create a new table. | |
dataTypeToSqlType(dataType: String): String | |
Map the database independant data type to a database dependant SQL data type. | |
destroyDatabase(name: String): Void | |
Destroy a database. | |
destroyTable(table: String): Void | |
Destroy a table. | |
getColumns(table: String): Array | |
Get column information. | |
getTables(): Array | |
Return list of tables in a database. | |
removeColumns(table: String, columns: Array): Void | |
Remove columns from a table. | |
removeIndex(table: String, index: String): Void | |
Remove an index. | |
renameColumn(table: String, oldColumn: String, newColumn: String): Void | |
Rename a column. | |
renameTable(oldTable: String, newTable: String): Void | |
Rename a table. | |
sql(cmd: String): Array | |
Execute a SQL command on the database. | |
sqlTypeToDataType(sqlType: String): String | |
Map the SQL type to a database independant data type. | |
sqlTypeToEjsType(sqlType: String): String | |
Map the SQL type to an Ejscript type class. |
Method Detail
- Description
- Add a column to a table.
- Description
- Change a column.
- Parameters
table: String Name of the table holding the column. column: String Name of the column to change. datatype: String Database independant type of the column. Valid types are: binary, boolean, date, datetime, decimal, float, integer, number, string, text, time and timestamp. options: Object Optional parameters.
close(): Void
- Description
- Close the database connection. Database connections should be closed when no longer needed rather than waiting for the garbage collector to automatically close the connection when disposing the database instance.
- Description
- Map the database independant data type to a database dependant SQL data type.
- Parameters
dataType: String Data type to map.
- Returns
- A string containing the name of the the corresponding SQL database type.
- Description
- Destroy a database.
- Parameters
name: String Name of the database to remove.
- Description
- Destroy a table.
- Parameters
table: String Name of the table to destroy.
- Description
- Get column information.
- Parameters
table: String Name of the table to examine.
- Returns
- An array of column data. This is database specific content and will vary depending on the database connector in use.
getTables(): Array
- Description
- Return list of tables in a database.
- Returns
- An array containing list of table names present in the currently opened database.
- Description
- Execute a SQL command on the database. This is a low level SQL command interface that bypasses logging. Use.
- Parameters
cmd: String SQL command to issue. Note: "SELECT" is automatically prepended and ";" is appended for you.
- Returns
- An array of row results where each row is represented by an Object hash containing the column names and values.
- Description
- Map the SQL type to a database independant data type.
- Parameters
sqlType: String Data type to map.
- Returns
- The corresponding database independant type.
- Description
- Map the SQL type to an Ejscript type class.
- Parameters
sqlType: String Data type to map.
- Returns
- The corresponding type class.