masterrecord 0.3.16 → 0.3.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Migrations/schema.js +10 -9
- package/SQLLiteEngine.js +72 -48
- package/context.js +48 -38
- package/deleteManager.js +11 -11
- package/insertManager.js +7 -7
- package/mySQLAsyncConnect.js +44 -0
- package/package.json +2 -2
- package/realMySQLEngine.js +836 -0
- package/test/parameterizedPlaceholderTest.js +1 -1
- package/mySQLEngine.js +0 -1105
- package/mySQLSyncConnect.js +0 -82
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Version 1.0.0 - MySQL async connection manager using mysql2/promise
|
|
2
|
+
const mysql = require('mysql2/promise');
|
|
3
|
+
|
|
4
|
+
class MySQLAsyncClient {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.config = {
|
|
7
|
+
host: config.host || 'localhost',
|
|
8
|
+
port: config.port || 3306,
|
|
9
|
+
user: config.user,
|
|
10
|
+
password: config.password,
|
|
11
|
+
database: config.database,
|
|
12
|
+
waitForConnections: true,
|
|
13
|
+
connectionLimit: config.connectionLimit || 10,
|
|
14
|
+
queueLimit: 0
|
|
15
|
+
};
|
|
16
|
+
this.pool = null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async connect() {
|
|
20
|
+
try {
|
|
21
|
+
this.pool = await mysql.createPool(this.config);
|
|
22
|
+
// Test connection
|
|
23
|
+
const connection = await this.pool.getConnection();
|
|
24
|
+
console.log('[MySQL] Connection pool initialized successfully');
|
|
25
|
+
connection.release();
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error('[MySQL] Connection failed:', error.message);
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getPool() {
|
|
33
|
+
return this.pool;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async close() {
|
|
37
|
+
if (this.pool) {
|
|
38
|
+
await this.pool.end();
|
|
39
|
+
console.log('[MySQL] Connection pool closed');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = MySQLAsyncClient;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "masterrecord",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.17",
|
|
4
4
|
"description": "An Object-relational mapping for the Master framework. Master Record connects classes to relational database tables to establish a database with almost zero-configuration ",
|
|
5
5
|
"main": "MasterRecord.js",
|
|
6
6
|
"bin": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"glob": "^13.0.0",
|
|
32
32
|
"deep-object-diff": "^1.1.9",
|
|
33
33
|
"pg": "^8.17.2",
|
|
34
|
-
"
|
|
34
|
+
"mysql2": "^3.11.5",
|
|
35
35
|
"app-root-path": "^3.1.0",
|
|
36
36
|
"better-sqlite3": "^12.6.2"
|
|
37
37
|
}
|