connect
- connect(service, id)
Establishes a connection to a Jnu-backed database, ensuring basic network connectivity, downloading (and caching) the database schema for service, and determining an identity to sign queries with. This is the usual way to obtain a
Connection().- Arguments:
service (string) – The service whose database to connect to. Must be a key in dcpConfig that has a services.jnu entry – in the default configuration, one of ‘scheduler’, ‘portal’, or ‘pxAuth’.
id – Optional. A Keystore or PrivateKey to sign queries as. If omitted, waits for a dcp/identity session to be established (identity.waitForSession()) and uses identity.get() – see the Identity API.
- Return type:
Promise<Connection>
The schema for a given service is downloaded once per process and cached; every connect() call for the same service reuses it.
Example
const jnu = require('dcp/jnu');
const db = await jnu.connect('portal');
console.log(db.schema.tables.jobs);