-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinterface.js
More file actions
46 lines (45 loc) · 876 Bytes
/
interface.js
File metadata and controls
46 lines (45 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const clients = new Map()
/**
* Driver Interface
* @class
*/
export default class DriverInterface {
/**
* configure a client with name
* @param {string} name
* @param {*} connection
* @returns {*}
*/
static configureWithName(name, client) {
return this.clients.set(name, client).get(name)
}
/**
* configure default client
* @param {*} connection
*/
static configure() {
return this.configureWithName.apply(this, ['default'].concat(Array.from(arguments)))
}
/**
* get a cient with name
* @param {string} name
* @returns {*}
*/
static getClient(name = 'default') {
return this.clients.get(name)
}
/**
* get default client
* @returns {*}
*/
static get client() {
return this.getClient()
}
/**
* get clients
* @returns {Map}
*/
static get clients() {
return clients
}
}