@simplysm/orm-node 13.0.41 → 13.0.43

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 +38 -3
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -37,7 +37,7 @@ 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.
40
+ - `createDbConn()` is a factory function that acquires connections from the connection pool and returns a `DbConn`.
41
41
  - `PooledDbConn` is a connection pool wrapper based on `generic-pool`, returning connections to the pool instead of closing them after use.
42
42
  - Each DBMS-specific connection class (`MysqlDbConn`, `MssqlDbConn`, `PostgresqlDbConn`) directly uses low-level DB drivers.
43
43
 
@@ -48,7 +48,7 @@ createOrm() (top-level entry point)
48
48
  | Function | Description |
49
49
  |----------|-------------|
50
50
  | `createOrm()` | ORM factory function. Takes a `DbContextDef` and connection settings to manage transaction-based connections. |
51
- | `createDbConn()` | Connection factory function. Caches connection pools by configuration and returns `PooledDbConn`. |
51
+ | `createDbConn()` | Connection factory function. Caches connection pools by configuration and returns a `DbConn` (backed by `PooledDbConn`). |
52
52
 
53
53
  ### Classes
54
54
 
@@ -197,7 +197,7 @@ const orm = createOrm(MyDb, {
197
197
 
198
198
  ### Low-Level Connection with createDbConn
199
199
 
200
- You can connect directly to the DB and execute SQL without `createOrm`/`DbContext`. `createDbConn()` returns `PooledDbConn` from the connection pool.
200
+ You can connect directly to the DB and execute SQL without `createOrm`/`DbContext`. `createDbConn()` returns a `DbConn` (backed by `PooledDbConn`) from the connection pool.
201
201
 
202
202
  ```typescript
203
203
  import { createDbConn } from "@simplysm/orm-node";
@@ -382,6 +382,41 @@ The common interface implemented by all DBMS-specific connection classes (`Mysql
382
382
 
383
383
  `DbConn` extends `EventEmitter<{ close: void }>`, so you can listen for connection close events with `on("close", handler)` / `off("close", handler)`.
384
384
 
385
+ ## NodeDbContextExecutor
386
+
387
+ `NodeDbContextExecutor` implements the `DbContextExecutor` interface from `@simplysm/orm-common`. It is used internally by `createOrm()` but can also be instantiated directly when you need fine-grained control over the executor lifecycle.
388
+
389
+ ```typescript
390
+ import { NodeDbContextExecutor } from "@simplysm/orm-node";
391
+
392
+ const executor = new NodeDbContextExecutor({
393
+ dialect: "mysql",
394
+ host: "localhost",
395
+ port: 3306,
396
+ username: "root",
397
+ password: "password",
398
+ database: "mydb",
399
+ });
400
+ ```
401
+
402
+ | Method | Signature | Description |
403
+ |--------|-----------|-------------|
404
+ | `connect()` | `() => Promise<void>` | Acquire a connection from the pool and activate it |
405
+ | `close()` | `() => Promise<void>` | Return the connection to the pool |
406
+ | `beginTransaction()` | `(isolationLevel?: IsolationLevel) => Promise<void>` | Begin a transaction |
407
+ | `commitTransaction()` | `() => Promise<void>` | Commit the current transaction |
408
+ | `rollbackTransaction()` | `() => Promise<void>` | Roll back the current transaction |
409
+ | `executeParametrized()` | `(query: string, params?: unknown[]) => Promise<unknown[][]>` | Execute a parameterized SQL query |
410
+ | `bulkInsert()` | `(tableName: string, columnMetas: Record<string, ColumnMeta>, records: DataRecord[]) => Promise<void>` | Delegate bulk insert to the underlying connection |
411
+ | `executeDefs()` | `(defs: QueryDef[], resultMetas?: (ResultMeta \| undefined)[]) => Promise<T[][]>` | Build SQL from `QueryDef` array, execute, and parse results using `ResultMeta` |
412
+
413
+ ### executeDefs behavior
414
+
415
+ `executeDefs()` is the core method used by `DbContext`. It:
416
+ - Builds SQL strings from `QueryDef` using the appropriate dialect query builder.
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`.
419
+
385
420
  ## Orm Interface
386
421
 
387
422
  The return type of `createOrm()`. Provides the `connect()` and `connectWithoutTransaction()` methods.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/orm-node",
3
- "version": "13.0.41",
3
+ "version": "13.0.43",
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/orm-common": "13.0.41",
24
- "@simplysm/core-common": "13.0.41"
23
+ "@simplysm/core-common": "13.0.43",
24
+ "@simplysm/orm-common": "13.0.43"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/pg": "^8.16.0",