@iamkirbki/database-handler-pg 4.0.1 → 4.0.2
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/index.d.ts +1 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -43
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import PostgresAdapter from "./PostgresAdapter.js";
|
|
3
|
-
import { PoolConfig } from "pg";
|
|
4
|
-
export declare class PostgresDatabase extends Database {
|
|
5
|
-
private constructor();
|
|
6
|
-
static create(config: PoolConfig): Promise<PostgresDatabase>;
|
|
7
|
-
close(): Promise<void>;
|
|
8
|
-
cleanDatabase(): Promise<void>;
|
|
9
|
-
}
|
|
1
|
+
export { default as PostgresAdapter } from "./PostgresAdapter.js";
|
|
10
2
|
export { PostgresSchemaBuilder } from "./PostgresSchemaBuilder.js";
|
|
11
3
|
export { PostgresTableSchemaBuilder } from "./PostgresTableSchemaBuilder.js";
|
|
12
|
-
export { PostgresAdapter };
|
|
13
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAElE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,45 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { Database } from "@iamkirbki/database-handler-core";
|
|
11
|
-
import PostgresAdapter from "./PostgresAdapter.js";
|
|
12
|
-
export class PostgresDatabase extends Database {
|
|
13
|
-
constructor(adapter) {
|
|
14
|
-
super(adapter);
|
|
15
|
-
this.adapter = adapter;
|
|
16
|
-
}
|
|
17
|
-
static create(config) {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const adapter = new PostgresAdapter();
|
|
20
|
-
yield adapter.connect(config);
|
|
21
|
-
return new PostgresDatabase(adapter);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
close() {
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
yield this.adapter.close();
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
cleanDatabase() {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
// Get all tables and drop them
|
|
32
|
-
const tables = yield this.adapter.prepare(`
|
|
33
|
-
SELECT tablename FROM pg_tables
|
|
34
|
-
WHERE schemaname = 'public'
|
|
35
|
-
`);
|
|
36
|
-
const result = yield tables.all();
|
|
37
|
-
for (const row of result) {
|
|
38
|
-
yield this.adapter.exec(`DROP TABLE IF EXISTS "${row.tablename}" CASCADE`);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
export { default as PostgresAdapter } from "./PostgresAdapter.js";
|
|
43
2
|
export { PostgresSchemaBuilder } from "./PostgresSchemaBuilder.js";
|
|
44
3
|
export { PostgresTableSchemaBuilder } from "./PostgresTableSchemaBuilder.js";
|
|
45
|
-
export { PostgresAdapter };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iamkirbki/database-handler-pg",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"author": "iamkirbki",
|
|
5
5
|
"description": "PostgreSQL adapter for @kirbkis-database-handler/core",
|
|
6
6
|
"license": "ISC",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"build": "tsc --build && tsc-alias"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@iamkirbki/database-handler-core": "^4.0.
|
|
31
|
+
"@iamkirbki/database-handler-core": "^4.0.2",
|
|
32
32
|
"pg": "^8.16.3"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|