mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 20:39:28 +00:00
Added method to expose the mysql2 database connection
This commit is contained in:
@@ -91,6 +91,14 @@ class DatabaseConnectionPool {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expose the database connection pool
|
||||||
|
* @type {Object}
|
||||||
|
*/
|
||||||
|
get pool() {
|
||||||
|
return this.#connectionPool;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the connection to the database
|
* Close the connection to the database
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ jest.mock('./DatabaseConnectionPool', () => {
|
|||||||
return jest.fn().mockImplementation(() => {
|
return jest.fn().mockImplementation(() => {
|
||||||
return {
|
return {
|
||||||
runQuery: mockRunQuery,
|
runQuery: mockRunQuery,
|
||||||
close: mockClose
|
close: mockClose,
|
||||||
|
pool: true
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -89,4 +89,10 @@ describe('DatabaseConnectionPool', () => {
|
|||||||
|
|
||||||
expect(() => dbp.runQuery(sql, params)).toThrow();
|
expect(() => dbp.runQuery(sql, params)).toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Getter for pool exists', () => {
|
||||||
|
const dbp = new DatabaseConnectionPool();
|
||||||
|
|
||||||
|
expect(dbp.pool).toBeTrue();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ class DatabaseConnectionPool {
|
|||||||
-connectionPool: Object
|
-connectionPool: Object
|
||||||
runQuery(sql, params): Object[] | Object
|
runQuery(sql, params): Object[] | Object
|
||||||
close(): void
|
close(): void
|
||||||
|
getPool(): Object
|
||||||
{static} validateQuery(sql, params): string
|
{static} validateQuery(sql, params): string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user