5htp-core 0.2.9-5 → 0.2.9-6

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "5htp-core",
3
3
  "description": "Convenient TypeScript framework designed for Performance and Productivity.",
4
- "version": "0.2.9-5",
4
+ "version": "0.2.9-6",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-core.git",
7
7
  "license": "MIT",
@@ -69,9 +69,6 @@ type TColsToUpsert<TData extends TObjetDonnees> = (
69
69
 
70
70
  const LogPrefix = '[database]'
71
71
 
72
- const equalities = (data: TObjetDonnees, keys = Object.keys(data)) =>
73
- keys.map(k => '' + k + ' = ' + mysql.escape( data[k] ))
74
-
75
72
  /*----------------------------------
76
73
  - CORE
77
74
  ----------------------------------*/
@@ -191,7 +188,7 @@ export default class SQL extends Service<Config, Hooks, Application> {
191
188
 
192
189
  const keyword = prefix === '&' ? ' AND ' : ', '
193
190
 
194
- value = Object.keys(value).length === 0 ? '1' : equalities(value).join( keyword );
191
+ value = Object.keys(value).length === 0 ? '1' : this.equalities(value).join( keyword );
195
192
 
196
193
  // String: `SET :${column} = ${data}` => `SET balance = 10`
197
194
  } else {
@@ -214,6 +211,9 @@ export default class SQL extends Service<Config, Hooks, Application> {
214
211
  }).join(' ').trim();
215
212
  }
216
213
 
214
+ public equalities = (data: TObjetDonnees, keys = Object.keys(data)) =>
215
+ keys.map(k => '' + k + ' = ' + mysql.escape( data[k] ))
216
+
217
217
  /*----------------------------------
218
218
  - OPERATIONS: LOW LEVELf
219
219
  ----------------------------------*/
@@ -336,8 +336,8 @@ export default class SQL extends Service<Config, Hooks, Application> {
336
336
  }
337
337
 
338
338
  // Create equalities
339
- const egalitesData = equalities(data).join(', ')
340
- const egalitesWhere = equalities(where).join(' AND ')
339
+ const egalitesData = this.equalities(data).join(', ')
340
+ const egalitesWhere = this.equalities(where).join(' AND ')
341
341
 
342
342
  // Build query
343
343
  return this.database.query(`
@@ -509,7 +509,7 @@ export default class SQL extends Service<Config, Hooks, Application> {
509
509
 
510
510
  const whereSql = typeof where === 'function' && where['string'] !== undefined
511
511
  ? where['string']
512
- : equalities(where).join(' AND ');
512
+ : this.equalities(where).join(' AND ');
513
513
 
514
514
  return this.database.query(`DELETE FROM ${table} WHERE ${whereSql};`, opts);
515
515
  }