querize 1.0.3 → 1.0.4
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 +24 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -85,25 +85,48 @@ querize.createPool({
|
|
|
85
85
|
## Connection Types
|
|
86
86
|
|
|
87
87
|
### Single Connection
|
|
88
|
+
- **Behavior**: Creates a new connection for each query and closes it immediately after execution.
|
|
89
|
+
- **Flow**:
|
|
90
|
+
SQL → execute → connect → query → disconnect → SQL → ...
|
|
91
|
+
- **Notes**: Very simple, but repeatedly opening and closing connections can cause performance overhead.
|
|
88
92
|
```typescript
|
|
89
93
|
const database = await querize.createConnect(options);
|
|
90
94
|
```
|
|
91
95
|
|
|
92
96
|
### Connection Pool
|
|
97
|
+
- **Behavior**: Uses a connection pool where multiple queries can reuse existing connections.
|
|
98
|
+
- **Flow**:
|
|
99
|
+
SQL → execute → connect → query → SQL → ...
|
|
100
|
+
- **Notes**: More efficient for high-frequency queries since connections are reused instead of created and destroyed each time.
|
|
93
101
|
```typescript
|
|
94
102
|
const database = await querize.createPool(options);
|
|
95
103
|
```
|
|
96
104
|
|
|
97
105
|
### Cluster
|
|
106
|
+
- **Behavior**: Manages multiple database instances and selectively connects to one depending on the query.
|
|
107
|
+
- **Flow**:
|
|
108
|
+
SQL → execute → connect [choose DB] → query → SQL → ...
|
|
109
|
+
- **Notes**: Useful in multi-database environments for load balancing or failover scenarios.
|
|
98
110
|
```typescript
|
|
99
111
|
const database = await querize.createCluster([option1, option2, ...]);
|
|
100
112
|
```
|
|
101
113
|
|
|
102
|
-
### Query-only (
|
|
114
|
+
### Query-only (for Debug)
|
|
115
|
+
- **Notes**: Method to inspect the SQL string of a query.
|
|
103
116
|
```typescript
|
|
104
117
|
const database = await querize.createQuery();
|
|
105
118
|
```
|
|
106
119
|
|
|
120
|
+
## Transaction Types
|
|
121
|
+
|
|
122
|
+
### `Singleton`
|
|
123
|
+
- **Behavior**: Each connection handles only a single SQL statement at a time.
|
|
124
|
+
- **Use case**: Simplifies query execution when only one statement per connection is required.
|
|
125
|
+
|
|
126
|
+
### `Transaction`
|
|
127
|
+
- **Behavior**: A single connection is used for multiple statements until an explicit `COMMIT` or `ROLLBACK` is executed.
|
|
128
|
+
- **Use case**: Ensures atomic operations and consistency across multiple queries.
|
|
129
|
+
|
|
107
130
|
## Usage Examples
|
|
108
131
|
|
|
109
132
|
### Basic Queries
|