mysql-orm-lite 1.0.0 → 1.0.1

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 CHANGED
@@ -355,6 +355,7 @@ Build and execute a SELECT query.
355
355
  | `having` | string | HAVING clause |
356
356
  | `limit` | number | LIMIT value |
357
357
  | `offset` | number | OFFSET value |
358
+ | `forUpdate` | boolean | Append FOR UPDATE for row-level locking (default: false) |
358
359
 
359
360
  ```javascript
360
361
  // Simple select
@@ -683,6 +684,7 @@ The `TransactionCRUD` class provides all CRUD methods available in the main API:
683
684
  | Method | Description |
684
685
  |--------|-------------|
685
686
  | `find(query, params?)` | Execute SELECT query |
687
+ | `findForUpdate(options)` | Execute locked SELECT (FOR UPDATE) |
686
688
  | `insert(table, data)` | Insert record |
687
689
  | `update(table, data, whereClause)` | Update records |
688
690
  | `delete(whereClause, table)` | Delete records |
@@ -704,6 +706,7 @@ The `TransactionCRUD` class provides all CRUD methods available in the main API:
704
706
  | `updateQuery(options)` | `buildAndExecuteUpdateQuery` |
705
707
  | `deleteWhere(options)` | `buildAndExecuteDeleteQuery` |
706
708
  | `remove(options)` | `buildAndExecuteDeleteQuery` |
709
+ | `findForUpdate(options)` | `buildAndExecuteSelectQuery` (with forUpdate: true) |
707
710
 
708
711
  #### Complete Transaction Example
709
712
 
@@ -184,6 +184,11 @@ class TransactionCRUD {
184
184
  return this.buildAndExecuteSelectQuery(options);
185
185
  }
186
186
 
187
+ async findForUpdate(options) {
188
+ options.forUpdate = true;
189
+ return this.buildAndExecuteSelectQuery(options);
190
+ }
191
+
187
192
  async query(options) {
188
193
  return this.buildAndExecuteSelectQuery(options);
189
194
  }
package/lib/crud.js CHANGED
@@ -133,7 +133,7 @@ const utils = {
133
133
  },
134
134
 
135
135
  _buildSelectQuery(options) {
136
- let { table, fields = '*', joins = [], where, orderBy, limit, offset, groupBy, having, alias } = options;
136
+ let { table, fields = '*', joins = [], where, orderBy, limit, offset, groupBy, having, alias, forUpdate = false } = options;
137
137
 
138
138
  if (fields && Array.isArray(fields) && fields.length > 0) {
139
139
  fields = fields.filter(field => field && field.trim() !== '').join(', ');
@@ -167,6 +167,10 @@ const utils = {
167
167
  if (typeof offset === 'number') query += ` OFFSET ${offset}`;
168
168
  }
169
169
 
170
+ if (forUpdate) {
171
+ query += ' FOR UPDATE';
172
+ }
173
+
170
174
  return { query, params: allParams };
171
175
  },
172
176
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysql-orm-lite",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A lightweight ORM for MySQL with connection pooling, query builder, and transaction support",
5
5
  "main": "index.js",
6
6
  "private": false,
@@ -23,7 +23,7 @@
23
23
  "license": "MIT",
24
24
  "repository": {
25
25
  "type": "git",
26
- "url": "https://github.com/Manikandan-Thonthiraj/mysql-orm-lite.git"
26
+ "url": "git+https://github.com/Manikandan-Thonthiraj/mysql-orm-lite.git"
27
27
  },
28
28
  "bugs": {
29
29
  "url": "https://github.com/Manikandan-Thonthiraj/mysql-orm-lite/issues"
@@ -38,4 +38,4 @@
38
38
  "devDependencies": {
39
39
  "mysql2": "^3.11.5"
40
40
  }
41
- }
41
+ }