new <abstract> RightTrackDB( agency )

Description

RightTrackDB Abstract Class

This is the abstract RightTrackDB Class that is used by the Right Track projects to query the SQLite Right Track Database.

An implementation of this Class, such as right-track-db-sqlite3, which uses the node sqlite3 module, is what will actually be used in the projects.

An implementation of this Class must have the following functions:

  • constructor({RightTrackAgency} agency):

  • this is used to initialize the SQLite database

  • agency: The RightTrackAgency this DB will be used to query. The agency must have the configuration properties set to the agency's id as well as the database location.

  • select({string} statement, {function} callback):

  • this is used to SELECT multiple rows from the SQLite database using the passed statement. It will return the rows using the passed callback function.

  • statement: the full SQLite SELECT statement

  • callback: the selectCallback function

  • get({string} statement, {function} callback):

  • this is used to SELECT a single row from the SQLite database using the passed statement. It will return the result using the passed callback function.

    • If no rows are selected, it will return undefined
    • If one row is selected, it will return the single row
    • If more than one row is selected, it will return the first row
  • statement: the full SQLite SELECT statement

  • callback: the getCallback function

Module: classes/RightTrackDB

Parameters
Name Type Description
agency RightTrackAgency

The Right Track Agency this DB will be used to query

Members


agency

Description

The RightTrackAgency this DB is used to query


id

Description

The Right Track Agency id code

Returns

location

Description

The path to the SQLite Right Track DB

Returns

Methods


<abstract> select( statement, callback )

Description

Select multiple rows from the database

Parameters
Name Type Description
statement string

Select Statement

callback function

selectCallback callback function


<abstract> get( statement, callback )

Description

Select a single row from the database. If no results are selected, this will return undefined. If more than 1 results are selected it will return the first result.

Parameters
Name Type Description
statement string

Select Statement

callback function

getCallback callback function

Type Definitions


selectCallback( error [, rows ] )

Description

This callback is performed after performing a SELECT query that can return multiple rows.

Parameters
Name Type Attributes Description
error Error

Database Query Error

rows Array.<object> <optional>

Selected rows

Details
function

getCallback( error [, row ] )

Description

This callback is performed after performing a SELECT query that will return the first row.

Parameters
Name Type Attributes Description
error Error

Database Query Error

row object <optional>

First selected row

Details
function