RightTrackDB

RightTrackDB

Right Track Database

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

Constructor

(abstract) new RightTrackDB(agency)

Source:

Right Track Database Constructor

Parameters:
Name Type Description
agency RightTrackAgency

The Right Track Agency this DB will be used to query

Members

agency

Source:

The RightTrackAgency this DB is used to query

id

Source:

The Right Track Agency id code

location

Source:

The path to the SQLite Right Track DB

Methods

(abstract) get(statement, callback)

Source:

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

(abstract) select(statement, callback)

Source:

Select multiple rows from the database

Parameters:
Name Type Description
statement string

Select Statement

callback function

selectCallback callback function

Type Definitions

getCallback(error, rowopt)

Source:

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

selectCallback(error, rowsopt)

Source:

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