@blazedpath/commons 0.0.8 → 0.0.10
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/blz-base/index.js +895 -893
- package/blz-cache/index.js +14 -25
- package/blz-core/index.js +349 -347
- package/blz-cryptography/index.js +49 -47
- package/blz-datetimes/index.js +350 -348
- package/blz-file/index.js +88 -83
- package/blz-hazelcast/index.js +103 -100
- package/blz-iterable/index.js +406 -404
- package/blz-json-schema/index.js +8 -6
- package/blz-jwt/index.js +92 -89
- package/blz-kafka/index.js +107 -105
- package/blz-math/index.js +129 -127
- package/blz-mongodb/index.js +35 -33
- package/blz-rds/index.js +46 -44
- package/blz-rds-mysql/index.js +11 -9
- package/blz-rds-mysqlx/index.js +12 -10
- package/blz-rds-oracle/index.js +104 -99
- package/blz-rds-postgres/index.js +13 -11
- package/blz-redis/index.js +125 -123
- package/blz-regex/index.js +24 -22
- package/blz-strings/index.js +167 -165
- package/blz-uuid/index.js +4 -2
- package/blz-yaml/index.js +19 -16
- package/package.json +1 -1
package/blz-rds-mysqlx/index.js
CHANGED
|
@@ -18,24 +18,26 @@ process.on('exit', async function () {
|
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
module.exports = {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
|
|
22
|
+
syntaxis: require("./syntaxis.json"),
|
|
23
|
+
executeProcedure,
|
|
23
24
|
executeSql: async function (connection, sql, parameters, options = {}) {
|
|
24
|
-
if(sql.indexOf("call") != -1
|
|
25
|
+
if (sql.indexOf("call") != -1) {
|
|
25
26
|
return await executeProcedure(connection, sql, parameters);
|
|
26
|
-
} else if(_.has(options, "bulkInsert")) {
|
|
27
|
-
return await executeBulkInsert(connection, sql, parameters, options);
|
|
28
|
-
} else if(_.has(options, "bulkMerge")) {
|
|
29
|
-
return await executeBulkMerge(connection, sql, parameters, options);
|
|
30
|
-
} else if(_.has(options, "queryOne") || _.has(options, "query")) {
|
|
27
|
+
} else if (_.has(options, "bulkInsert")) {
|
|
28
|
+
return await executeBulkInsert(connection, sql, parameters, options);
|
|
29
|
+
} else if (_.has(options, "bulkMerge")) {
|
|
30
|
+
return await executeBulkMerge(connection, sql, parameters, options);
|
|
31
|
+
} else if (_.has(options, "queryOne") || _.has(options, "query")) {
|
|
31
32
|
return await executeQuery(connection, sql, parameters, options);
|
|
32
33
|
} else {
|
|
33
34
|
return await executeNonQuery(connection, sql, parameters, options);
|
|
34
35
|
}
|
|
35
36
|
},
|
|
36
|
-
beginTransaction,
|
|
37
|
+
beginTransaction,
|
|
37
38
|
close,
|
|
38
39
|
createRdsConnection,
|
|
39
40
|
commitTransaction,
|
|
40
|
-
rollbackTransaction
|
|
41
|
+
rollbackTransaction
|
|
42
|
+
|
|
41
43
|
}
|
package/blz-rds-oracle/index.js
CHANGED
|
@@ -31,8 +31,8 @@ const getPool = async function (connection) {
|
|
|
31
31
|
connection = _.omit(connection, "dataSource", "providerName");
|
|
32
32
|
connection.sessionCallback = makeInitSessionCallback({ schema: connection.schema })
|
|
33
33
|
// Enable instant client mode in Node.js
|
|
34
|
-
if (process.env.LD_LIBRARY_PATH){
|
|
35
|
-
oracledb.initOracleClient(
|
|
34
|
+
if (process.env.LD_LIBRARY_PATH) {
|
|
35
|
+
oracledb.initOracleClient({ libDir: process.env.LD_LIBRARY_PATH, configDir: '', thin: false });
|
|
36
36
|
}
|
|
37
37
|
pool = await oracledb.createPool(connection);
|
|
38
38
|
pool.connectionName = connection.name;
|
|
@@ -68,13 +68,13 @@ const tryDatetime = function (value) {
|
|
|
68
68
|
if (match) {
|
|
69
69
|
const probableDate = new Date(value);
|
|
70
70
|
if (probableDate.toString() !== 'Invalid Date') {
|
|
71
|
-
return probableDate;
|
|
71
|
+
return probableDate;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
return null;
|
|
76
76
|
};
|
|
77
|
-
const convertMilliseconds = function(strMilliseconds) {
|
|
77
|
+
const convertMilliseconds = function (strMilliseconds) {
|
|
78
78
|
if (strMilliseconds) {
|
|
79
79
|
if (strMilliseconds.length < 3)
|
|
80
80
|
strMilliseconds = strMilliseconds.padEnd(3, '0');
|
|
@@ -127,15 +127,15 @@ const getParameterType = function (type) {
|
|
|
127
127
|
case 'VARCHAR2':
|
|
128
128
|
return oracledb.STRING;
|
|
129
129
|
default:
|
|
130
|
-
return oracledb.STRING
|
|
130
|
+
return oracledb.STRING
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
const getOraParameters = function (parameters,options) {
|
|
134
|
+
const getOraParameters = function (parameters, options) {
|
|
135
135
|
let oraParameters = {};
|
|
136
136
|
if (parameters)
|
|
137
137
|
for (let i = 0; i < parameters.length; i++) {
|
|
138
|
-
let parameter = parameters[i];
|
|
138
|
+
let parameter = parameters[i];
|
|
139
139
|
let oraParameter = {};
|
|
140
140
|
// checks if i need to convert nodejs to oracle representation (bool -> 0,1) etcs
|
|
141
141
|
if (parameter.direction === 'in' || parameter.direction === 'in/out') {
|
|
@@ -175,7 +175,7 @@ const getOraParameters = function (parameters,options) {
|
|
|
175
175
|
if (parameter.isResultSet)
|
|
176
176
|
oraParameter.type = oracledb.CURSOR;
|
|
177
177
|
else {
|
|
178
|
-
if (parameter.dbTypes){
|
|
178
|
+
if (parameter.dbTypes) {
|
|
179
179
|
const oracleEntry = parameter.dbTypes.find(entry => entry.providerName === 'Oracle');
|
|
180
180
|
parameter.dbType = getParameterType(oracleEntry.dbType);
|
|
181
181
|
} else if (parameter.type) {
|
|
@@ -193,7 +193,7 @@ const getOraParameters = function (parameters,options) {
|
|
|
193
193
|
return oraParameters
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
const getOraOptions = function (options
|
|
196
|
+
const getOraOptions = function (options, bindDefs) {
|
|
197
197
|
let oraOptions = { autoCommit: !options.isTransactionRequest };
|
|
198
198
|
if (options && (options.query || options.queryOne)) {
|
|
199
199
|
oraOptions.resultSet = true;
|
|
@@ -210,29 +210,29 @@ const convertValueFromType = async function (value, type) {
|
|
|
210
210
|
return BlzBase.convertToString(value);
|
|
211
211
|
}
|
|
212
212
|
case 'integer': {
|
|
213
|
-
return
|
|
213
|
+
return BlzBase.convertToInteger(value);
|
|
214
214
|
}
|
|
215
215
|
case 'decimal': {
|
|
216
|
-
return
|
|
216
|
+
return BlzBase.convertToDecimal(value);
|
|
217
217
|
}
|
|
218
218
|
case 'boolean': {
|
|
219
|
-
return
|
|
219
|
+
return BlzBase.convertToBoolean(value);
|
|
220
220
|
}
|
|
221
221
|
case 'datetime': {
|
|
222
|
-
return
|
|
222
|
+
return BlzBase.convertToDatetime(value);
|
|
223
223
|
}
|
|
224
224
|
case 'date': {
|
|
225
|
-
return
|
|
225
|
+
return BlzBase.convertToDate(value);
|
|
226
226
|
}
|
|
227
227
|
case 'time': {
|
|
228
|
-
return
|
|
228
|
+
return BlzBase.convertToTime(value);
|
|
229
229
|
}
|
|
230
230
|
case 'binary': {
|
|
231
|
-
return
|
|
231
|
+
return BlzBase.convertToBinary(value);
|
|
232
232
|
}
|
|
233
|
-
default:{
|
|
233
|
+
default: {
|
|
234
234
|
// If i have a clob, or special type, the case might not be straightforward
|
|
235
|
-
if (value._type.name === 'DB_TYPE_CLOB'
|
|
235
|
+
if (value._type.name === 'DB_TYPE_CLOB') {
|
|
236
236
|
return await oraResult.outBinds[parameter.name].getData();
|
|
237
237
|
}
|
|
238
238
|
}
|
|
@@ -288,19 +288,19 @@ process.on('exit', async function () {
|
|
|
288
288
|
});
|
|
289
289
|
|
|
290
290
|
const getValue = function (source, type) {
|
|
291
|
-
const _type =
|
|
291
|
+
const _type = type ? type.toLowerCase() : typeof source
|
|
292
292
|
switch (_type.toLowerCase()) {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
293
|
+
case 'boolean':
|
|
294
|
+
return source ? 1 : 0
|
|
295
|
+
case 'string':
|
|
296
|
+
return typeof source === 'string' || source === null || source === undefined ? source : source.toString()
|
|
297
|
+
case 'datetime':
|
|
298
|
+
case 'date':
|
|
299
|
+
case 'time':
|
|
300
|
+
return source ? new Date(source) : null
|
|
301
|
+
default:
|
|
302
|
+
return source
|
|
303
|
+
}
|
|
304
304
|
}
|
|
305
305
|
|
|
306
306
|
/**
|
|
@@ -343,10 +343,10 @@ const rowsToArray = function (columns, rows) {
|
|
|
343
343
|
const columnsCount = columns.length
|
|
344
344
|
for (const row of rows) {
|
|
345
345
|
const item = {}
|
|
346
|
-
for(let i=0
|
|
347
|
-
const column = columns[i]
|
|
346
|
+
for (let i = 0; i < columnsCount; i++) {
|
|
347
|
+
const column = columns[i]
|
|
348
348
|
const value = row[i]
|
|
349
|
-
item[column.name] = getValue(value,column.type)
|
|
349
|
+
item[column.name] = getValue(value, column.type)
|
|
350
350
|
}
|
|
351
351
|
array.push(item)
|
|
352
352
|
}
|
|
@@ -354,11 +354,12 @@ const rowsToArray = function (columns, rows) {
|
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
module.exports = {
|
|
357
|
+
|
|
357
358
|
syntaxis: require('./syntaxis.json'),
|
|
358
359
|
createRdsConnection: async function (connection) {
|
|
359
360
|
try {
|
|
360
361
|
let oraPool = await getPool(connection);
|
|
361
|
-
let oraConnection = await oraPool.getConnection();
|
|
362
|
+
let oraConnection = await oraPool.getConnection();
|
|
362
363
|
return oraConnection;
|
|
363
364
|
}
|
|
364
365
|
catch (err) {
|
|
@@ -366,17 +367,17 @@ module.exports = {
|
|
|
366
367
|
}
|
|
367
368
|
},
|
|
368
369
|
executeSql: async function (connection, sql, parameters, options) {
|
|
369
|
-
if(_.has(options, "bulkInsert")) {
|
|
370
|
-
return await this._executeBulkInsert(connection, sql, parameters, options);
|
|
371
|
-
} else if(_.has(options, "bulkMerge")) {
|
|
372
|
-
return await this._executeBulkMerge(connection, sql, parameters, options);
|
|
370
|
+
if (_.has(options, "bulkInsert")) {
|
|
371
|
+
return await this._executeBulkInsert(connection, sql, parameters, options);
|
|
372
|
+
} else if (_.has(options, "bulkMerge")) {
|
|
373
|
+
return await this._executeBulkMerge(connection, sql, parameters, options);
|
|
373
374
|
} else {
|
|
374
375
|
return await this._executeSql(connection, sql, parameters, options);
|
|
375
376
|
}
|
|
376
377
|
},
|
|
377
378
|
_executeSql: async function (connection, sql, parameters, options) {
|
|
378
|
-
try{
|
|
379
|
-
let oraParameters = getOraParameters(parameters,options);
|
|
379
|
+
try {
|
|
380
|
+
let oraParameters = getOraParameters(parameters, options);
|
|
380
381
|
let oraOptions = getOraOptions(options)
|
|
381
382
|
let oraResult = await connection.execute(sql, oraParameters, oraOptions);
|
|
382
383
|
const result = await getResult(parameters, oraResult, options);
|
|
@@ -387,42 +388,43 @@ module.exports = {
|
|
|
387
388
|
},
|
|
388
389
|
_executeBulkInsert: async function (connection, sql, rows, options) {
|
|
389
390
|
let autoincremental = null
|
|
390
|
-
if (options.autoincrementalData && options.autoincrementalData.pkColumnName) {
|
|
391
|
-
autoincremental = {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
391
|
+
if (options.autoincrementalData && options.autoincrementalData.pkColumnName) {
|
|
392
|
+
autoincremental = {
|
|
393
|
+
name: options.autoincrementalData.pkColumnName,
|
|
394
|
+
alias: options.autoincrementalData.pkColumnAlias,
|
|
395
|
+
sequence: options.autoincrementalData.sequenceName,
|
|
396
|
+
type: options.autoincrementalData.pkColumnType
|
|
397
|
+
}
|
|
396
398
|
}
|
|
397
|
-
const _sql = autoincremental ?
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
399
|
+
const _sql = autoincremental ?
|
|
400
|
+
'INSERT INTO ' + options.rdsTable.tableName +
|
|
401
|
+
' (' + autoincremental.name + ',' + options.setsFields.join(', ') +
|
|
402
|
+
') VALUES ( ' + autoincremental.sequence + '.NEXTVAL, ' + options.setsFields.map((field) => ':' + field).join(', ') + ' ) ' +
|
|
403
|
+
' RETURNING ' + autoincremental.name + ' INTO :' + autoincremental.name
|
|
404
|
+
: sql + '(' + options.setsFields.map((field) => ':' + field).join(', ') + ' ) '
|
|
405
|
+
|
|
404
406
|
// solve max size for string fields
|
|
405
|
-
const columnsCount = options.columns.length
|
|
406
|
-
|
|
407
|
+
const columnsCount = options.columns.length
|
|
408
|
+
for (let i = 0; i < columnsCount; i++) {
|
|
407
409
|
const column = options.columns[i]
|
|
408
410
|
if (column.type === 'string') {
|
|
409
|
-
column.size =
|
|
411
|
+
column.size = rows.reduce((max, row) => { return !row[i] ? 0 : row[i].length > max ? row[i].length : max }, 0)
|
|
410
412
|
}
|
|
411
413
|
}
|
|
412
414
|
const bindDefs = {}
|
|
413
|
-
|
|
414
|
-
const bindDef = { type:getDbType(column.type) }
|
|
415
|
+
for (const column of options.columns) {
|
|
416
|
+
const bindDef = { type: getDbType(column.type) }
|
|
415
417
|
if (column.type === 'string') {
|
|
416
418
|
bindDef.maxSize = column.size
|
|
417
419
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
+
bindDefs[column.name] = bindDef
|
|
421
|
+
}
|
|
420
422
|
if (autoincremental) {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
const oraOptions = getOraOptions(options,bindDefs)
|
|
424
|
-
const data = rowsToArray(options.columns,rows)
|
|
425
|
-
try {
|
|
423
|
+
bindDefs[autoincremental.name] = { type: getDbType(autoincremental.type), dir: oracledb.BIND_OUT }
|
|
424
|
+
}
|
|
425
|
+
const oraOptions = getOraOptions(options, bindDefs)
|
|
426
|
+
const data = rowsToArray(options.columns, rows)
|
|
427
|
+
try {
|
|
426
428
|
const result = await connection.executeMany(_sql, data, oraOptions)
|
|
427
429
|
if (autoincremental) {
|
|
428
430
|
const ids = []
|
|
@@ -436,93 +438,94 @@ module.exports = {
|
|
|
436
438
|
} catch (err) {
|
|
437
439
|
console.log(err)
|
|
438
440
|
throw err
|
|
439
|
-
}
|
|
441
|
+
}
|
|
440
442
|
},
|
|
441
443
|
_executeBulkMerge: async function (connection, sql, rows, options) {
|
|
442
444
|
// example: https://stackoverflow.com/questions/67881781/how-to-execute-multiple-merge-into-query-on-oracle-db-from-node-js
|
|
443
445
|
let autoincremental = null
|
|
444
|
-
if (options.autoincrementalData && options.autoincrementalData.pkColumnName) {
|
|
445
|
-
autoincremental = {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
446
|
+
if (options.autoincrementalData && options.autoincrementalData.pkColumnName) {
|
|
447
|
+
autoincremental = {
|
|
448
|
+
name: options.autoincrementalData.pkColumnName,
|
|
449
|
+
alias: options.autoincrementalData.pkColumnAlias,
|
|
450
|
+
sequence: options.autoincrementalData.sequenceName,
|
|
451
|
+
type: options.autoincrementalData.pkColumnType
|
|
452
|
+
}
|
|
450
453
|
}
|
|
451
454
|
const _sql = []
|
|
452
|
-
_sql.push('MERGE INTO ' + options.rdsTable.tableName + ' t USING (')
|
|
455
|
+
_sql.push('MERGE INTO ' + options.rdsTable.tableName + ' t USING (')
|
|
453
456
|
_sql.push('SELECT ')
|
|
454
457
|
let first = true
|
|
455
458
|
for (const column of options.columns) {
|
|
456
|
-
_sql.push((first?'': ', ') + ':' + column.name + ' AS ' + column.name)
|
|
459
|
+
_sql.push((first ? '' : ', ') + ':' + column.name + ' AS ' + column.name)
|
|
457
460
|
first = false
|
|
458
461
|
}
|
|
459
462
|
_sql.push('FROM DUAL')
|
|
460
463
|
_sql.push(') s ON (')
|
|
461
|
-
first = true
|
|
462
|
-
for(const field of options.mergeFields) {
|
|
463
|
-
_sql.push((first?'': ' AND ') + 't.' + field + ' = s.' + field
|
|
464
|
+
first = true
|
|
465
|
+
for (const field of options.mergeFields) {
|
|
466
|
+
_sql.push((first ? '' : ' AND ') + 't.' + field + ' = s.' + field)
|
|
464
467
|
first = false
|
|
465
468
|
}
|
|
466
469
|
_sql.push(')')
|
|
467
470
|
_sql.push('WHEN MATCHED THEN UPDATE SET ')
|
|
468
471
|
first = true
|
|
469
|
-
for(const column of options.columns) {
|
|
470
|
-
if(options.mergeFields.includes(column.name)) continue
|
|
471
|
-
_sql.push((first?'': ',') + 't.' + column.name + ' = s.' + column.name)
|
|
472
|
+
for (const column of options.columns) {
|
|
473
|
+
if (options.mergeFields.includes(column.name)) continue
|
|
474
|
+
_sql.push((first ? '' : ',') + 't.' + column.name + ' = s.' + column.name)
|
|
472
475
|
first = false
|
|
473
476
|
}
|
|
474
477
|
_sql.push('WHEN NOT MATCHED THEN INSERT (')
|
|
475
|
-
if(autoincremental) {
|
|
478
|
+
if (autoincremental) {
|
|
476
479
|
_sql.push(autoincremental.name)
|
|
477
|
-
for(const column of options.columns) {
|
|
480
|
+
for (const column of options.columns) {
|
|
478
481
|
_sql.push(',' + column.name)
|
|
479
482
|
}
|
|
480
483
|
_sql.push(') VALUES (')
|
|
481
484
|
_sql.push(autoincremental.sequence + '.NEXTVAL')
|
|
482
|
-
for(const column of options.columns) {
|
|
485
|
+
for (const column of options.columns) {
|
|
483
486
|
_sql.push(',s.' + column.name)
|
|
484
487
|
}
|
|
485
488
|
} else {
|
|
486
489
|
first = true
|
|
487
|
-
for(const column of options.columns) {
|
|
488
|
-
_sql.push((first?'': ',') + column.name)
|
|
490
|
+
for (const column of options.columns) {
|
|
491
|
+
_sql.push((first ? '' : ',') + column.name)
|
|
489
492
|
first = false
|
|
490
493
|
}
|
|
491
494
|
_sql.push(') VALUES (')
|
|
492
495
|
first = true
|
|
493
|
-
for(const column of options.columns) {
|
|
494
|
-
_sql.push((first?'': ',') + 's.' + column.name)
|
|
496
|
+
for (const column of options.columns) {
|
|
497
|
+
_sql.push((first ? '' : ',') + 's.' + column.name)
|
|
495
498
|
first = false
|
|
496
499
|
}
|
|
497
500
|
}
|
|
498
501
|
_sql.push(')')
|
|
499
502
|
const mergeSql = _sql.join(' ')
|
|
500
|
-
|
|
503
|
+
|
|
501
504
|
// solve max size for string fields
|
|
502
|
-
const columnsCount = options.columns.length
|
|
503
|
-
|
|
505
|
+
const columnsCount = options.columns.length
|
|
506
|
+
for (let i = 0; i < columnsCount; i++) {
|
|
504
507
|
const column = options.columns[i]
|
|
505
508
|
if (column.type === 'string') {
|
|
506
|
-
column.size =
|
|
509
|
+
column.size = rows.reduce((max, row) => { return !row[i] ? 0 : row[i].length > max ? row[i].length : max }, 0)
|
|
507
510
|
}
|
|
508
511
|
}
|
|
509
512
|
const bindDefs = {}
|
|
510
|
-
|
|
511
|
-
const bindDef = { type:getDbType(column.type) }
|
|
513
|
+
for (const column of options.columns) {
|
|
514
|
+
const bindDef = { type: getDbType(column.type) }
|
|
512
515
|
if (column.type === 'string') {
|
|
513
516
|
bindDef.maxSize = column.size
|
|
514
517
|
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
const oraOptions = getOraOptions(options,bindDefs)
|
|
518
|
-
const data = rowsToArray(options.columns,rows)
|
|
519
|
-
try {
|
|
518
|
+
bindDefs[column.name] = bindDef
|
|
519
|
+
}
|
|
520
|
+
const oraOptions = getOraOptions(options, bindDefs)
|
|
521
|
+
const data = rowsToArray(options.columns, rows)
|
|
522
|
+
try {
|
|
520
523
|
const result = await connection.executeMany(mergeSql, data, oraOptions)
|
|
521
524
|
return { rowsAffected: result.rowsAffected }
|
|
522
525
|
} catch (err) {
|
|
523
526
|
console.log(err)
|
|
524
527
|
throw err
|
|
525
|
-
}
|
|
528
|
+
}
|
|
526
529
|
},
|
|
527
530
|
close(nativeConnection) {
|
|
528
531
|
return nativeConnection.close();
|
|
@@ -536,4 +539,6 @@ module.exports = {
|
|
|
536
539
|
rollbackTransaction(nativeConnection) {
|
|
537
540
|
return nativeConnection.rollback();
|
|
538
541
|
}
|
|
542
|
+
|
|
543
|
+
|
|
539
544
|
};
|
|
@@ -18,24 +18,26 @@ process.on('exit', async function () {
|
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
module.exports = {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
|
|
22
|
+
syntaxis: require('./syntaxis.json'),
|
|
23
|
+
executeProcedure,
|
|
23
24
|
executeSql: async function (connection, sql, parameters, options = {}) {
|
|
24
|
-
if(sql.indexOf("call") != -1
|
|
25
|
+
if (sql.indexOf("call") != -1) {
|
|
25
26
|
return await executeProcedure(connection, sql, parameters);
|
|
26
|
-
} else if(_.has(options, "bulkInsert")) {
|
|
27
|
-
return await executeBulkInsert(connection, sql, parameters, options);
|
|
28
|
-
} else if(_.has(options, "bulkMerge")) {
|
|
29
|
-
return await executeBulkMerge(connection, sql, parameters, options);
|
|
30
|
-
} else if(_.has(options, "queryOne") || _.has(options, "query")) {
|
|
27
|
+
} else if (_.has(options, "bulkInsert")) {
|
|
28
|
+
return await executeBulkInsert(connection, sql, parameters, options);
|
|
29
|
+
} else if (_.has(options, "bulkMerge")) {
|
|
30
|
+
return await executeBulkMerge(connection, sql, parameters, options);
|
|
31
|
+
} else if (_.has(options, "queryOne") || _.has(options, "query")) {
|
|
31
32
|
return await executeQuery(connection, sql, parameters, options);
|
|
32
33
|
} else {
|
|
33
|
-
return await executeNonQuery(connection, sql, parameters, options
|
|
34
|
+
return await executeNonQuery(connection, sql, parameters, options);
|
|
34
35
|
}
|
|
35
36
|
},
|
|
36
|
-
beginTransaction,
|
|
37
|
+
beginTransaction,
|
|
37
38
|
close,
|
|
38
39
|
createRdsConnection,
|
|
39
40
|
commitTransaction,
|
|
40
|
-
rollbackTransaction
|
|
41
|
+
rollbackTransaction
|
|
42
|
+
|
|
41
43
|
}
|