|
1 | 1 | export = DbHelper; |
2 | | - |
3 | 2 | /** |
4 | 3 | * Database helper for CodeceptJS |
5 | 4 | * |
6 | 5 | * @author Thiago Delgado Pinto |
7 | 6 | */ |
8 | 7 | declare class DbHelper { |
9 | | - |
10 | | - /** |
11 | | - * Constructor |
12 | | - * |
13 | | - * @param {object} config CodeceptJS configuration. |
14 | | - */ |
15 | | - constructor(config: object); |
16 | | - |
17 | | - /** |
18 | | - * Connects to the database described by the given connection string. |
19 | | - * |
20 | | - * @param {string|number} key Identification for using in other commands. |
21 | | - * @param {string|object} conn JDBC-like connection string or a connection object accepted by `database-js`. |
22 | | - * @param {object|undefined} [driver] [OPTIONAL] Driver object, used by `database-js`. |
23 | | - * |
24 | | - * @returns {Connection} DatabaseJS' connection |
25 | | - */ |
26 | | - connect(key: string | number, conn: string | object, driver?: object): any; |
27 | | - |
28 | | - |
29 | | - /** |
30 | | - * Disconnects and removes the database connection identified by the given key. |
31 | | - * |
32 | | - * @param {string|number} key Database identification key set in connect(). |
33 | | - * |
34 | | - * @returns {Promise<boolean>} If it was successful. |
35 | | - */ |
36 | | - disconnect(key: string | number): Promise<boolean>; |
37 | | - |
38 | | - /** |
39 | | - * Disconnects and removes the database connection identified by the given key. |
40 | | - * |
41 | | - * @param {string|number} key Database identification key set in connect(). |
42 | | - * |
43 | | - * @returns {Promise<boolean>} If it was successful. |
44 | | - */ |
45 | | - removeConnection(key: string | number): Promise<boolean>; |
46 | | - |
47 | | - /** |
48 | | - * Performs a query. |
49 | | - * |
50 | | - * @param {string|number} key Database identification key set in connect(). |
51 | | - * @param {string} command Query to run. |
52 | | - * @param {...any[]|undefined} [params] [OPTIONAL] Query parameters. |
53 | | - * |
54 | | - * @returns {Promise<any[]>} Query results. |
55 | | - */ |
56 | | - query(key: string | number, command: string, ...params: any[]): Promise<any[]>; |
57 | | - |
58 | | - |
59 | | - /** |
60 | | - * Executes a command. |
61 | | - * |
62 | | - * @param {string|number} key Database identification key set in connect(). |
63 | | - * @param {string} command Command to run. |
64 | | - * @param {any[]} [params] [OPTIONAL] Command parameters. |
65 | | - * |
66 | | - * @returns {Promise<any[]>} Command results. |
67 | | - */ |
68 | | - run(key: string | number, command: string, ...params: any[]): Promise<any[]>; |
69 | | - |
70 | | - /** |
71 | | - * Creates a database connection. |
72 | | - * |
73 | | - * @param {string|object} conn JDBC-like connection string or a connection object accepted by `database-js`. |
74 | | - * @param {object|undefined} [driver] [OPTIONAL] Driver object, used by `database-js`. |
75 | | - * |
76 | | - * @returns {Connection} DatabaseJS' connection |
77 | | - */ |
78 | | - createConnection(conn: string | object, driver?: object): any; |
79 | | - |
80 | | - /** |
81 | | - * Checks if there is a database connection with the given key. |
82 | | - * |
83 | | - * @param {string|number} key Database identification key set in connect(). |
84 | | - * |
85 | | - * @returns {boolean} |
86 | | - */ |
87 | | - hasConnection(key: string | number): boolean; |
88 | | - |
89 | | - /** |
90 | | - * Gets the database connection with the given key. |
91 | | - * |
92 | | - * @param {string|number} key Database identification key set in connect(). |
93 | | - * |
94 | | - * @returns {Connection} DatabaseJS' connection. |
95 | | - */ |
96 | | - getConnection(key: string | number): any; |
97 | | - |
| 8 | + /** |
| 9 | + * Constructor |
| 10 | + * |
| 11 | + * @param {object} config CodeceptJS configuration. |
| 12 | + */ |
| 13 | + constructor(config: object); |
| 14 | + options: any; |
| 15 | + connectionMap: {}; |
| 16 | + /** |
| 17 | + * Connects to the database described by the given connection string. |
| 18 | + * |
| 19 | + * @param {string|number} key Identification for using in other commands. |
| 20 | + * @param {string|object} conn JDBC-like connection string or a connection object accepted by `database-js`. |
| 21 | + * @param {object|undefined} [driver] [OPTIONAL] Driver object, used by `database-js`. |
| 22 | + * |
| 23 | + * @returns {Connection} DatabaseJS' connection |
| 24 | + */ |
| 25 | + connect(key: string | number, conn: string | object, driver?: object | undefined): any; |
| 26 | + /** |
| 27 | + * Disconnects and removes the database connection identified by the given key. |
| 28 | + * |
| 29 | + * @param {string|number} key Database identification key set in connect(). |
| 30 | + * |
| 31 | + * @returns {Promise<boolean>} If it was successful. |
| 32 | + */ |
| 33 | + disconnect(key: string | number): Promise<boolean>; |
| 34 | + /** |
| 35 | + * Disconnects and removes the database connection identified by the given key. |
| 36 | + * |
| 37 | + * @param {string|number} key Database identification key set in connect(). |
| 38 | + * |
| 39 | + * @returns {Promise<boolean>} If it was successful. |
| 40 | + */ |
| 41 | + removeConnection(key: string | number): Promise<boolean>; |
| 42 | + /** |
| 43 | + * Performs a query. |
| 44 | + * |
| 45 | + * @param {string|number} key Database identification key set in connect(). |
| 46 | + * @param {string} command Query to run. |
| 47 | + * @param {...any[]|undefined} [params] [OPTIONAL] Query parameters. |
| 48 | + * |
| 49 | + * @returns {Promise<any[]>} Query results. |
| 50 | + */ |
| 51 | + query(key: string | number, command: string, ...params?: (any[] | undefined)[]): Promise<any[]>; |
| 52 | + /** |
| 53 | + * Executes a command. |
| 54 | + * |
| 55 | + * @param {string|number} key Database identification key set in connect(). |
| 56 | + * @param {string} command Command to run. |
| 57 | + * @param {any[]} [params] [OPTIONAL] Command parameters. |
| 58 | + * |
| 59 | + * @returns {Promise<any[]>} Command results. |
| 60 | + */ |
| 61 | + run(key: string | number, command: string, ...params?: any[]): Promise<any[]>; |
| 62 | + /** |
| 63 | + * Creates a database connection. |
| 64 | + * |
| 65 | + * @param {string|object} conn JDBC-like connection string or a connection object accepted by `database-js`. |
| 66 | + * @param {object|undefined} [driver] [OPTIONAL] Driver object, used by `database-js`. |
| 67 | + * |
| 68 | + * @returns {Connection} DatabaseJS' connection |
| 69 | + */ |
| 70 | + createConnection(conn: string | object, driver?: object | undefined): any; |
| 71 | + /** |
| 72 | + * Checks if there is a database connection with the given key. |
| 73 | + * |
| 74 | + * @param {string|number} key Database identification key set in connect(). |
| 75 | + * |
| 76 | + * @returns {boolean} |
| 77 | + */ |
| 78 | + hasConnection(key: string | number): boolean; |
| 79 | + /** |
| 80 | + * Gets the database connection with the given key. |
| 81 | + * |
| 82 | + * @param {string|number} key Database identification key set in connect(). |
| 83 | + * |
| 84 | + * @returns {Connection} DatabaseJS' connection. |
| 85 | + */ |
| 86 | + getConnection(key: string | number): any; |
| 87 | + /** |
| 88 | + * Creates an error that represents a database not found. |
| 89 | + * |
| 90 | + * @param {string|number} key Database identification key. |
| 91 | + */ |
| 92 | + _keyNotFoundError(key: string | number): Error; |
98 | 93 | } |
0 commit comments