Total Complexity | 3 |
Complexity/F | 3 |
Lines of Code | 28 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import mariadb from 'mariadb'; |
||
2 | |||
3 | const pool = mariadb.createPool({ |
||
4 | host: process.env.DB_HOST, |
||
5 | user: 'root', |
||
6 | database: process.env.DB_DATABASE, |
||
7 | password: process.env.DB_PASSWORD, |
||
8 | // connectionLimit: 5 |
||
9 | }); |
||
10 | |||
11 | export const db = { |
||
12 | pool: pool, |
||
13 | |||
14 | getUsers: async function() { |
||
15 | let conn; |
||
16 | |||
17 | try { |
||
18 | conn = await pool.getConnection(); |
||
19 | let sql = `CALL all_users();`; |
||
20 | let res = await conn.query(sql); |
||
21 | return res[0]; |
||
22 | } catch (err) { |
||
|
|||
23 | // do something |
||
24 | } finally { |
||
25 | if (conn) conn.end(); |
||
26 | } |
||
27 | } |
||
28 | } |