Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DB

Control the database through a single object.

Hierarchy

  • DB

Constructors

constructor

  • new DB(dbURL: string): DB
  • Database controller constructor.

    Parameters

    • dbURL: string

      Database connection URL.

    Returns DB

    Database controller object.

Properties

Private closed

closed: boolean = false

Private conn

conn: DBConnection = null

Private pool

pool: Pool

Connection pool.

Methods

close

  • close(): Promise<void>
  • Close the connection to the database.

    Returns Promise<void>

commit

  • commit(): Promise<void>
  • Commit a transaction.

    Returns Promise<void>

execute

  • execute(stmt: string, params?: any[]): Promise<any[]>
  • Execute a SQL query.

    Parameters

    • stmt: string

      SQL statement.

    • params: any[] = ...

      Values to be inserted into the statement.

    Returns Promise<any[]>

    Query results.

executeMany

  • executeMany(stmts: string[], params?: any[][]): Promise<any[][]>
  • Execute multiple SQL queries, each one right after the last

    Parameters

    • stmts: string[]

      SQL statement.

    • params: any[][] = ...

      Values to be inserted into the statement.

    Returns Promise<any[][]>

    Results of all queries.

getConnection

  • Get a single connection object from the pool.

    Returns Promise<DBConnection>

    The connection object.

rollback

  • rollback(): Promise<void>
  • Rollback a transaction.

    Returns Promise<void>

setConnection

  • Set the database controller's current connection object. null can be passed to use the connection pool.

    Parameters

    Returns void

startTransaction

  • startTransaction(): Promise<void>
  • Start a transaction.

    Returns Promise<void>

Generated using TypeDoc