@simplysm/orm-node 13.0.58 → 13.0.60

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.
Files changed (2) hide show
  1. package/README.md +25 -5
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -37,9 +37,9 @@ createOrm() (top-level entry point)
37
37
 
38
38
  - `createOrm()` is the top-level factory function that takes a `DbContextDef` and connection settings to manage transactions.
39
39
  - `NodeDbContextExecutor` is the executor used by `DbContext`, converting `QueryDef` to SQL and executing it.
40
- - `createDbConn()` is a factory function that acquires connections from the connection pool and returns a `DbConn`.
40
+ - `createDbConn()` is a factory function that creates a `PooledDbConn` wrapper synchronously; actual pool acquisition happens when `connect()` is called on the returned object.
41
41
  - `PooledDbConn` is a connection pool wrapper based on `generic-pool`, returning connections to the pool instead of closing them after use.
42
- - Each DBMS-specific connection class (`MysqlDbConn`, `MssqlDbConn`, `PostgresqlDbConn`) directly uses low-level DB drivers.
42
+ - Each DBMS-specific connection class (`MysqlDbConn`, `MssqlDbConn`, `PostgresqlDbConn`) directly uses low-level DB drivers. These are not intended for direct instantiation — use `createDbConn()` instead.
43
43
 
44
44
  ## Main Modules
45
45
 
@@ -202,7 +202,7 @@ You can connect directly to the DB and execute SQL without `createOrm`/`DbContex
202
202
  ```typescript
203
203
  import { createDbConn } from "@simplysm/orm-node";
204
204
 
205
- // Create connection (acquire from pool)
205
+ // Create connection wrapper (pool acquisition happens on connect())
206
206
  const conn = await createDbConn({
207
207
  dialect: "mysql",
208
208
  host: "localhost",
@@ -401,7 +401,7 @@ const executor = new NodeDbContextExecutor({
401
401
 
402
402
  | Method | Signature | Description |
403
403
  |--------|-----------|-------------|
404
- | `connect()` | `() => Promise<void>` | Acquire a connection from the pool and activate it |
404
+ | `connect()` | `() => Promise<void>` | Create a `PooledDbConn` via `createDbConn()` and call `connect()` to acquire from pool |
405
405
  | `close()` | `() => Promise<void>` | Return the connection to the pool |
406
406
  | `beginTransaction()` | `(isolationLevel?: IsolationLevel) => Promise<void>` | Begin a transaction |
407
407
  | `commitTransaction()` | `() => Promise<void>` | Commit the current transaction |
@@ -415,7 +415,27 @@ const executor = new NodeDbContextExecutor({
415
415
  `executeDefs()` is the core method used by `DbContext`. It:
416
416
  - Builds SQL strings from `QueryDef` using the appropriate dialect query builder.
417
417
  - If all `resultMetas` entries are `undefined`, combines all SQL into a single batch execution and returns empty arrays (used for write-only operations to minimize round-trips).
418
- - Otherwise, executes each `QueryDef` individually and parses results through `parseQueryResult()` using the corresponding `ResultMeta`.
418
+ - Otherwise, executes each `QueryDef` individually and parses results through `parseQueryResult()` using the corresponding `ResultMeta`. When `ResultMeta` contains `resultSetIndex`, that index selects the correct result set from multi-result-set responses (relevant for MSSQL stored procedures, etc.).
419
+
420
+ ## PooledDbConn
421
+
422
+ `PooledDbConn` wraps a physical DBMS connection with pool management. Key behaviors:
423
+
424
+ - **`config` getter**: Returns the inner connection's config if connected, otherwise falls back to the config passed at creation.
425
+ - **`isConnected` / `isInTransaction`**: Delegated to the inner physical connection.
426
+ - **`connect()`**: Acquires a physical connection from `generic-pool`. If the pool factory fails, the error is reported with context from the last creation error.
427
+ - **`close()`**: If a transaction is in progress, automatically attempts rollback before returning the connection to the pool. Emits a `close` event.
428
+
429
+ ## OrmOptions
430
+
431
+ Options object passed as the third argument to `createOrm()`.
432
+
433
+ | Field | Type | Description |
434
+ |-------|------|-------------|
435
+ | `database` | `string \| undefined` | Override the `database` from `DbConnConfig` for use in DbContext queries |
436
+ | `schema` | `string \| undefined` | Override the `schema` from `DbConnConfig` for use in DbContext queries |
437
+
438
+ These overrides affect SQL generation (table prefixing) without changing the physical connection target.
419
439
 
420
440
  ## Orm Interface
421
441
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/orm-node",
3
- "version": "13.0.58",
3
+ "version": "13.0.60",
4
4
  "description": "심플리즘 패키지 - ORM 모듈 (node)",
5
5
  "author": "김석래",
6
6
  "license": "Apache-2.0",
@@ -20,8 +20,8 @@
20
20
  "dependencies": {
21
21
  "consola": "^3.4.2",
22
22
  "generic-pool": "^3.9.0",
23
- "@simplysm/core-common": "13.0.58",
24
- "@simplysm/orm-common": "13.0.58"
23
+ "@simplysm/core-common": "13.0.60",
24
+ "@simplysm/orm-common": "13.0.60"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/pg": "^8.16.0",