Database
Module | ejs.db |
Namespace | "ejs.db" |
Definition | class Database |
Inheritance | Database ![]() |
SQLite database support.
Properties
Qualifiers | Property | Type | Description |
---|---|---|---|
public static const | DatatypeToSqlite | Object | |
public static const | SqliteToDatatype | Object | |
public static const | SqliteToEjs | Object |
Database Methods
Qualifiers | Method |
---|---|
public | addColumn(table: String, column: String, datatype: String, options: Object): Void |
public | addIndex(table: String, column: String, indexName: String): Void |
public | changeColumn(table: String, column: String, datatype: String, options: Object): Void |
public | close(): Void |
Close the database connection. | |
public | connect(connectionString: String): Void |
Reconnect to the database using a new connection string. | |
public get | connection(): String |
Get the database connection string. | |
public | createDatabase(name: String, options: Object): Void |
public | createTable(table: String, columns: Array): Void |
Database(connectionString: String) | |
Initialize a SQLite database connection using the supplied database connection string. | |
public static set | defaultDatabase(db: Database): Void |
Set the default database for the application. | |
public static get | defaultDatabase(): Database |
Get the default database for the application. | |
public | destroyDatabase(name: String): Void |
public | destroyTable(table: String): Void |
public | getColumns(table: String): Array |
public | getTables(): Array |
Return list of tables in a database. | |
public get | name(): String |
Get the name of the database. | |
public | query(cmd: String): Array |
Execute a SQL command on the database. | |
public | removeColumns(table: String, columns: Array): Void |
public | removeIndex(table: String, indexName: String): Void |
public | renameColumn(table: String, oldColumn: String, newColumn: String): Void |
public | renameTable(oldTable: String, newTable: String): Void |
public | sql(cmd: String): Array |
Execute a SQL command on the database. | |
public static | trace(on: Boolean): Void |
Trace SQL statements. |
Method Detail
public close(): Void
Close the database connection.
- Description
- 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.
Reconnect to the database using a new connection string.
- Parameters
connectionString: String See Database() for information about connection string formats.
get public connection(): String
Get the database connection string.
Database(connectionString: String)
Initialize a SQLite database connection using the supplied database connection string.
- Parameters
connectionString: String Connection string stipulating how to connect to the database. The format is one of the following forms: - filename
- adapter://host/database/username/password
- filename
Set the default database for the application.
- Parameters
static get public defaultDatabase(): Database
Get the default database for the application.
- Returns
- The default database defined via the $defaultDatabase setter method.
public getTables(): Array
Return list of tables in a database.
- Returns
- An array containing list of table names present in the currently opened database.
get public name(): String
Get the name of the database.
- Returns
- The database name defined via the connection string.
Execute a SQL command on the database.
- Parameters
- Returns
- An array of row results where each row is represented by an Object hash containing the column names and values.
Execute a SQL command on the database.
- Description
- This is a low level SQL command interface that bypasses logging. Use.
- Parameters
- Returns
- An array of row results where each row is represented by an Object hash containing the column names and values.
Trace SQL statements.
- Description
- Control whether trace is enabled for the actual SQL statements issued against the database.
- Parameters
on: Boolean If true, display each SQL statement to the log