pg-query-sdk 1.0.4 → 1.2.0
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/README.md +1 -32
- package/package.json +32 -7
package/README.md
CHANGED
|
@@ -136,8 +136,6 @@ const db = new Database({
|
|
|
136
136
|
async function transactionExample() {
|
|
137
137
|
try {
|
|
138
138
|
const result = await db.transaction(async trxDb => {
|
|
139
|
-
// 'trxDb' is a Database instance bound to the current transaction.
|
|
140
|
-
// Use 'trxDb.executor.execute()' for DML operations within the transaction.
|
|
141
139
|
await trxDb.executor.execute(
|
|
142
140
|
'UPDATE accounts SET balance = balance - $1 WHERE id = $2',
|
|
143
141
|
[100.00, 1]
|
|
@@ -181,9 +179,6 @@ class UserRepository extends Repository<User> {
|
|
|
181
179
|
.where({ name })
|
|
182
180
|
.execute();
|
|
183
181
|
}
|
|
184
|
-
|
|
185
|
-
// Implement DML operations as needed.
|
|
186
|
-
// Example: async insert(data: Partial<User>): Promise<User> { /* ... */ }
|
|
187
182
|
}
|
|
188
183
|
|
|
189
184
|
const db = new Database({
|
|
@@ -212,7 +207,7 @@ The package provides support for both CommonJS and ES Modules environments.
|
|
|
212
207
|
### CommonJS
|
|
213
208
|
|
|
214
209
|
```javascript
|
|
215
|
-
const Database = require('pg-query-sdk')
|
|
210
|
+
const {Database} = require('pg-query-sdk');
|
|
216
211
|
const db = new Database({ /* ... */ });
|
|
217
212
|
```
|
|
218
213
|
|
|
@@ -225,32 +220,6 @@ const db = new Database({ /* ... */ });
|
|
|
225
220
|
|
|
226
221
|
---
|
|
227
222
|
|
|
228
|
-
## 🧱 Project Structure
|
|
229
|
-
|
|
230
|
-
The project is organized into distinct modules, each responsible for a specific aspect of database interaction:
|
|
231
|
-
|
|
232
|
-
```
|
|
233
|
-
pg-query-sdk/
|
|
234
|
-
src/
|
|
235
|
-
core/
|
|
236
|
-
Database.ts # Central database interface
|
|
237
|
-
ParamContext.ts # Manages query parameters
|
|
238
|
-
QueryExecutor.ts # Executes SQL queries
|
|
239
|
-
TransactionManager.ts # Handles database transactions
|
|
240
|
-
builders/
|
|
241
|
-
ConditionBuilder.ts # Builds WHERE/HAVING clauses
|
|
242
|
-
QueryBuilder.ts # Builds SELECT queries
|
|
243
|
-
orm/
|
|
244
|
-
EntityManager.ts # (Planned) Entity management
|
|
245
|
-
Repository.ts # Abstract base for data access
|
|
246
|
-
dialects/
|
|
247
|
-
Dialect.ts # Interface for database dialects
|
|
248
|
-
PostgresDialect.ts # PostgreSQL specific dialect implementation
|
|
249
|
-
index.ts # Main entry point for module exports
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
---
|
|
253
|
-
|
|
254
223
|
## 📌 Responsibilities of Layers
|
|
255
224
|
|
|
256
225
|
| Layer | Responsibility |
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pg-query-sdk",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "PostgreSQL SDK with Query Builder and
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "PostgreSQL SDK with Query Builder, Query Executor and Transaction Manager",
|
|
5
|
+
"type": "commonjs",
|
|
5
6
|
"main": "dist/cjs/index.js",
|
|
6
7
|
"types": "dist/esm/index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=18"
|
|
11
|
+
},
|
|
7
12
|
"exports": {
|
|
8
13
|
".": {
|
|
9
14
|
"require": "./dist/cjs/index.js",
|
|
@@ -15,11 +20,29 @@
|
|
|
15
20
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
16
21
|
"build:esm": "tsc -p tsconfig.esm.json",
|
|
17
22
|
"build": "npm run build:cjs && npm run build:esm",
|
|
23
|
+
"lint": "echo \"Add lint later\"",
|
|
24
|
+
"test": "echo \"Add tests\"",
|
|
18
25
|
"prepublishOnly": "npm run build"
|
|
19
26
|
},
|
|
20
27
|
"files": [
|
|
21
28
|
"dist"
|
|
22
29
|
],
|
|
30
|
+
"keywords": [
|
|
31
|
+
"postgresql",
|
|
32
|
+
"postgres",
|
|
33
|
+
"typescript",
|
|
34
|
+
"nodejs",
|
|
35
|
+
"database",
|
|
36
|
+
"sql",
|
|
37
|
+
"query-builder",
|
|
38
|
+
"sdk",
|
|
39
|
+
"orm",
|
|
40
|
+
"transaction",
|
|
41
|
+
"cte",
|
|
42
|
+
"repository-pattern",
|
|
43
|
+
"query-engine",
|
|
44
|
+
"prepared-statement"
|
|
45
|
+
],
|
|
23
46
|
"author": {
|
|
24
47
|
"name": "Guilherme",
|
|
25
48
|
"email": "sguii5147@gmail.com",
|
|
@@ -27,19 +50,21 @@
|
|
|
27
50
|
},
|
|
28
51
|
"repository": {
|
|
29
52
|
"type": "git",
|
|
30
|
-
"url": "https://github.com/guio11221/pg-query-sdk.git"
|
|
53
|
+
"url": "git+https://github.com/guio11221/pg-query-sdk.git"
|
|
31
54
|
},
|
|
32
55
|
"bugs": {
|
|
33
56
|
"url": "https://github.com/guio11221/pg-query-sdk/issues"
|
|
34
57
|
},
|
|
35
58
|
"homepage": "https://github.com/guio11221/pg-query-sdk#readme",
|
|
36
59
|
"license": "MIT",
|
|
37
|
-
"dependencies": {
|
|
38
|
-
|
|
60
|
+
"dependencies": {},
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"pg": "^8.0.0"
|
|
39
63
|
},
|
|
40
64
|
"devDependencies": {
|
|
41
65
|
"typescript": "^5.3.3",
|
|
42
66
|
"@types/node": "^20.10.5",
|
|
43
|
-
"@types/pg": "^8.16.0"
|
|
67
|
+
"@types/pg": "^8.16.0",
|
|
68
|
+
"pg": "^8.18.0"
|
|
44
69
|
}
|
|
45
|
-
}
|
|
70
|
+
}
|