@aceitadev/adatabase 0.6.1 → 0.6.3
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/dist/Database.js
CHANGED
|
@@ -26,13 +26,13 @@ function init(dbType, config) {
|
|
|
26
26
|
adapter = new PostgresAdapter_1.PostgresAdapter();
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
|
-
throw new Error(`
|
|
29
|
+
throw new Error(`Database type not supported: ${dbType}`);
|
|
30
30
|
}
|
|
31
31
|
adapter.init(config);
|
|
32
32
|
}
|
|
33
33
|
function getAdapter() {
|
|
34
34
|
if (!adapter) {
|
|
35
|
-
throw new Error("
|
|
35
|
+
throw new Error("Database not initialized. Call init() first.");
|
|
36
36
|
}
|
|
37
37
|
return adapter;
|
|
38
38
|
}
|
package/dist/SchemaManager.js
CHANGED
|
@@ -45,7 +45,7 @@ class SchemaManager {
|
|
|
45
45
|
if (this.changes.size === 0) {
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
console.log("
|
|
48
|
+
console.log("Database Updated:");
|
|
49
49
|
const tableEntries = Array.from(this.changes.entries());
|
|
50
50
|
tableEntries.forEach(([table, changes], tableIndex) => {
|
|
51
51
|
const isLastTable = tableIndex === tableEntries.length - 1;
|
|
@@ -58,7 +58,7 @@ class SchemaManager {
|
|
|
58
58
|
const isLastChange = changeIndex === changes.length - 1;
|
|
59
59
|
const changeLinePrefix = isLastTable ? " " : "│ ";
|
|
60
60
|
const changeConnector = isLastChange ? "└─" : "├─";
|
|
61
|
-
console.log(`${changeLinePrefix}${changeConnector} ${change}`);
|
|
61
|
+
console.log(`${changeLinePrefix} ${changeConnector} ${change}`);
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
64
|
}
|
|
@@ -22,21 +22,21 @@ class MySQLAdapter {
|
|
|
22
22
|
init(config) {
|
|
23
23
|
var _a;
|
|
24
24
|
if (this.pool) {
|
|
25
|
-
console.warn("[
|
|
25
|
+
console.warn("[aDatabase] MySQL connection pool already initialized.");
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
try {
|
|
29
29
|
this.pool = promise_1.default.createPool(Object.assign(Object.assign({}, config), { waitForConnections: true, connectionLimit: (_a = config.connectionLimit) !== null && _a !== void 0 ? _a : 10, queueLimit: 0 }));
|
|
30
|
-
console.log("[
|
|
30
|
+
console.log("[aDatabase] MySQL connection pool initialized.");
|
|
31
31
|
}
|
|
32
32
|
catch (error) {
|
|
33
|
-
console.error("[
|
|
33
|
+
console.error("[aDatabase] MySQL connection pool initialization failed:", error);
|
|
34
34
|
process.exit(1);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
getPool() {
|
|
38
38
|
if (!this.pool) {
|
|
39
|
-
throw new Error("
|
|
39
|
+
throw new Error("MySQL connection pool not initialized.");
|
|
40
40
|
}
|
|
41
41
|
return this.pool;
|
|
42
42
|
}
|
|
@@ -18,23 +18,23 @@ class PostgresAdapter {
|
|
|
18
18
|
}
|
|
19
19
|
init(config) {
|
|
20
20
|
if (this.pool) {
|
|
21
|
-
console.warn("[
|
|
21
|
+
console.warn("[aDatabase] Connection pool already initialized.");
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
try {
|
|
25
25
|
this.pool = new pg_1.Pool({
|
|
26
26
|
connectionString: config.url,
|
|
27
27
|
});
|
|
28
|
-
console.log("[
|
|
28
|
+
console.log("[aDatabase] PostgreSQL connection pool initialized.");
|
|
29
29
|
}
|
|
30
30
|
catch (error) {
|
|
31
|
-
console.error("[
|
|
31
|
+
console.error("[aDatabase] PostgreSQL connection pool initialization failed:", error);
|
|
32
32
|
process.exit(1);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
getPool() {
|
|
36
36
|
if (!this.pool) {
|
|
37
|
-
throw new Error("
|
|
37
|
+
throw new Error("PostgreSQL connection pool not initialized.");
|
|
38
38
|
}
|
|
39
39
|
return this.pool;
|
|
40
40
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aceitadev/adatabase",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Uma biblioteca para facilitar a interação com bancos de dados MySQL e PostgreSQL em projetos TypeScript/Node.js.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|