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

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

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 statem,ent, if not set this property is skipped

prepareUpsertExpr(req) → {string}

Description:
  • Build UPSERT or ON CONFLICT statement

Source:
Parameters:
Name Type Description
req DbRequest
Returns:
Type Description
string

full SQL text or nothing to use default

query(client, req, callback)

Description:
  • Execute a query in req.text

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