SqlPool

SqlPool

Create a database pool for SQL like databases, see dbPool

Constructor

new SqlPool(options, defaultsopt)

Source:
Parameters:
Name Type Attributes Description
options object

an object defining the pool, the following properties define the pool:

Properties
Name Type Description
pool string

pool name/type, if not specified the SQLite is used

max int

max number of clients to be allocated in the pool, 25 default for SQL but can be set to 0 for drivers like Rqlite or RDS Data.

idle int

after how many milliseconds an idle client will be destroyed

defaults object <optional>

an object with default pool methods for init and shutdown and other properties, see Pool

Methods

nextToken(client, req, rows) → {object}

Description:
  • Support for pagination, for SQL this is the OFFSET for the next request

Source:
Parameters:
Name Type Description
client object
req DbRequest
rows Array.<object>
Returns:
Type Description
object

placeholder(req, value) → {string}

Description:
  • Add an new placeholder for the given value, i.e. $1, ?, ....

Source:
Parameters:
Name Type Description
req DbRequest
value any

value to added to req.values

Returns:
Type Description
string

prepare(req)

Description:
  • Prepare for execution, return an object with formatted or transformed SQL query for the database driver of this pool

Source:
Parameters:
Name Type Description
req DbRequest

prepareExpr(req, name, value, columnopt) → {string}

Description:
  • Build expression

Source:
Parameters:
Name Type Attributes Description
req DbRequest
name string

property name

value any

current value

column DbRequestColumn <optional>

column definition returned by module.db:prepareColumn

Returns:
Type Description
string

prepareUpdateExpr(req, expr)

Description:
  • SQL SET expression for a column

Source:
Parameters:
Name Type Description
req DbRequest
expr object
Properties
Name Type Attributes Description
name string

property name

type string

column type

column string

quoted column name to use in SQL

value any

current value

op string

default op

text string

must be set to complete SET statement, if not set this property is skipped

placeholder string <optional>

set placeholder if needed

query(client, req, callback)

Description:
  • Execute a query in req.text

Source:
Parameters:
Name Type Description
client object
req DbRequest
callback function()