-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New: mysql2 and sqlite3 support (fixes #1)
- Loading branch information
Showing
22 changed files
with
1,659 additions
and
1,403 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict' | ||
|
||
/** | ||
* Create a connection pool | ||
* @param {Object} opts | ||
* @param {string} opts.client | ||
* @param {string} opts.host | ||
* @param {string} opts.port | ||
* @param {string} opts.user | ||
* @param {string} opts.password | ||
* @param {string} opts.appName - In some RDMS, appName is used as the name of the database | ||
* @param {string} opts.database | ||
* @param {string} opts.connectionLimit | ||
* @returns {Pool} the connection pool | ||
*/ | ||
function Jorma_mysql({ client, host, port, user, password, appName, database, connectionLimit }) { | ||
if (client != 'mysql' && client != 'mysql2') { | ||
throw new Error(`Unsupported mysql client ${client}`) | ||
} | ||
return require(client).createPool({ | ||
connectionLimit, | ||
host, | ||
port, | ||
user, | ||
password, | ||
// some RDMS use appName to locate the database instead of the actual db, though the table_schema stored in infomation_schema.columns is still the latter one. | ||
database: appName || database | ||
}) | ||
} | ||
|
||
module.exports = Jorma_mysql |
Oops, something went wrong.