Database

Moduleejs.db
Namespace"ejs.db"
Definition class Database
InheritanceDatabase inherit Object

SQLite database support.


Properties

QualifiersPropertyTypeDescription
No properties defined

Database Methods

QualifiersMethod
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.

public connect(connectionString: String): Void

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
In the future, connection strings will support other databases using a format a format like:
  • 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 public defaultDatabase(db: Database): Void

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.

public query(sql: String): Array

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.