Database
| Module | ejs.db |
| Namespace | "ejs.db" |
| Definition | class Database |
| Inheritance | Database Object |
SQLite database support.
Properties
| Qualifiers | Property | Type | Description |
|---|---|---|---|
| No properties defined | |||
Database Methods
| Qualifiers | Method |
|---|---|
| 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. | |
| Database(connectionString: String) | |
| Initialize a SQLite database connection using the supplied database connection string. | |
| public get | defaultDatabase(): Database |
| Get the default database for the application. | |
| public set | defaultDatabase(db: Database): Void |
| Set the default database for the application. | |
| public get | name(): String |
| Get the name of the database. | |
| public | query(sql: String): Array |
| Execute a SQL command on the database. | |
| public get | tables(): Array |
| Return list of tables in a database. |
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
get public defaultDatabase(): Database
Get the default database for the application.
- Returns
- The default database defined via the $defaultDatabase setter method.
Set the default database for the application.
- Parameters
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
sql: String SQL command string
- Returns
- An array of row results where each row is represented by an Object hash containing the column names and values.
get public tables(): Array
Return list of tables in a database.
- Returns
- An array containing list of table names present in the currently opened database.