Client abstraction to manage connections to the database, at the moment,
only using an internal connection pool.
Example
const mysqlx = require('@mysqlx/xdevapi') const client = mysqlx.getClient('mysqlx://root@localhost') return client.getSession() .then(session => { // A new session is created using a connection from the pool. })
Methods
-
close()
-
Client destructor (closes and cleans up all the connections in the pool).
Returns:
- Type
- Promise
Example
const client = mysqlx.getClient({ user: 'root' }, { pooling: { enabled: true, maxSize: 3 } }) client.getSession() .then(() => client.close());
-
getSession()
-
Create a new session using a connection from the pool (if one is available).
Returns:
The active session instance.- Type
- Promise.<Session>
Example
const client = mysqlx.getClient({ user: 'root' }, { pooling: { enabled: true, maxSize: 3 } }) client.getSession() .then(session => { console.log(session.inspect()); // { pooling: true, ... } })
Type Definitions
-
Properties
-
Extended client options.
Type:
- Object
Properties:
Name Type Argument Description pooling
module:ConnectionPool~Properties <optional>
connection pool configuration