query(query, values, qrm) {
                if (!ctx.db) {
                    return $p.reject(new Error(npm.text.queryDisconnected));
                }
                return config.$npm.query.call(this, ctx, query, values, qrm);
            }
@method Database#connect

@description
Acquires a new or existing connection, depending on the current state of the connection pool, and parameter `direct`.

This method creates a shared connection for executing a chain of queries against it. The connection must be released
in the end of the chain by calling `done()` on the connection object.

Method `done` takes one optional parameter - boolean `kill` flag, to signal the connection pool that you want it to kill
the physical connection. This flag is ignored for direct connections, as they always close when released.

It should not be used just for chaining queries on the same connection, methods {@link Database#task task} and
{@link Database#tx tx} (for transactions) are to be used for that. This method is primarily for special cases, like
`LISTEN` notifications.

**NOTE:** Even though this method exposes a {@link external:Client Client} object via property `client`,
you cannot call `client.end()` directly, or it will print an error into the console:
`Abnormal client.end() call, due to invalid code or failed server connection.`
You should only call method `done()` to release the connection.

@param {object} [options]
Connection Options.

@param {boolean} [options.direct=false]
Creates a new connection directly, as a stand-alone {@link external:Client Client} object, bypassing the connection pool.

By default, all connections are acquired from the connection pool. But if you set this option, the library will instead
create a new {@link external:Client Client} object directly (separately from the pool), and then call its `connect` method.

Note that specifically for direct connections, method `done` returns a {@link external:Promise Promise}, because those connections
are closed physically, which may take time.

**WARNING:**

Do not use this option for regular query execution, because it exclusively occupies one physical channel, and it cannot scale.
This option is only suitable for global connection usage, such as event listeners.

@param {function} [options.onLost]
Notification callback of the lost/broken connection, called with the following parameters:
 - `err` - the original connectivity error
 - `e` - error context object, which contains:
   - `cn` - safe connection string/config (with the password hashed);
   - `dc` - Database Context, as was used during {@link Database} construction;
   - `start` - Date/Time (`Date` type) when the connection was established;
   - `client` - {@link external:Client Client} object that has lost the connection.

The notification is mostly valuable with `direct: true`, to be able to re-connect direct/permanent connections by calling
method {@link Database#connect connect} again.

You do not need to call `done` on lost connections, as it happens automatically. However, if you had event listeners
set up on the connection's `client` object, you should remove them to avoid leaks:

```js
function onLostConnection(err, e) {
    e.client.removeListener('my-event', myHandler);
}
```

For a complete example see $[Robust Listeners].

@returns {external:Promise}
A promise object that represents the connection result:
 - resolves with the complete {@link Database} protocol, extended with:
   - property `client` of type {@link external:Client Client} that represents the open connection
   - method `done` that must be called in the end, in order to release the connection (returns a {@link external:Promise Promise}
     in case of direct connections)
   - methods `batch`, `page` and `sequence`, same as inside a {@link Task}
 - rejects with a connection-related error when it fails to connect.

@see
{@link Database#task Database.task},
{@link Database#taskIf Database.taskIf},
{@link Database#tx Database.tx},
{@link Database#txIf Database.txIf}

@example

let sco; // shared connection object;

db.connect()
    .then(obj => {
        // obj.client = new connected Client object;

        sco = obj; // save the connection object;

        // execute all the queries you need:
        return sco.any('SELECT * FROM Users');
    })
    .then(data => {
        // success
    })
    .catch(error => {
        // error
    })
    .finally(() => {
        // release the connection, if it was successful:
        if (sco) {
            // if you pass `true` into method done, i.e. done(true),
            // it will make the pool kill the physical connection.
            sco.done();
        }
    });