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

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, indexopt) → {string}

Description:
  • Return full placeholder for the given index, i.e. $1, ?, ....

Source:
Parameters:
Name Type Attributes Description
req DbRequest
index int <optional>

if not provided req.values.length is used

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

placeholder string

placeholder position, like $1, unsetting this property means the value should not be added to req.values

text string

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

query(client, req, callback)

Description:
  • Execute a query in req.text

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