@blazedpath/commons 0.0.9 → 0.0.11
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 +5 -5
- package/blz-kafka/index.js +1 -1
- package/blz-rds-mysql/index.js +22 -22
- package/blz-rds-mysqlx/index.js +22 -22
- package/blz-rds-oracle/index.js +164 -164
- package/blz-rds-postgres/index.js +22 -22
- package/package.json +1 -1
package/blz-base/index.js
CHANGED
|
@@ -536,7 +536,7 @@ module.exports = {
|
|
|
536
536
|
},
|
|
537
537
|
transform: async function (callContext, transformationName, source, writer) {
|
|
538
538
|
let transformation = _metadata[transformationName];
|
|
539
|
-
let transformationExecutor = require('../sources/'
|
|
539
|
+
let transformationExecutor = require(Path.join(_metadata.appPath,'../sources/', transformation.sourceFileName));
|
|
540
540
|
if (source) {
|
|
541
541
|
if (source._blz_reader) { // reader
|
|
542
542
|
let reader = source;
|
|
@@ -579,7 +579,7 @@ module.exports = {
|
|
|
579
579
|
writer: function (callContext, functionName, extraArgs) {
|
|
580
580
|
let fn
|
|
581
581
|
try {
|
|
582
|
-
fn = require('../sources/'
|
|
582
|
+
fn = require(Path.join(_metadata.appPath,'../sources/',module.exports.Dual.ensureDashedFormat(functionName) + '.js'))
|
|
583
583
|
}
|
|
584
584
|
catch (err) {
|
|
585
585
|
throw this.error('InvalidFunction', { functionName: functionName });
|
|
@@ -742,7 +742,7 @@ module.exports = {
|
|
|
742
742
|
internalCall: async function (callContext, functionName, args) {
|
|
743
743
|
let fn = null;
|
|
744
744
|
try {
|
|
745
|
-
fn = require('../sources/'
|
|
745
|
+
fn = require(Path.join(_metadata.appPath,'../sources/', module.exports.Dual.ensureDashedFormat(functionName) + '.js'))
|
|
746
746
|
}
|
|
747
747
|
catch (err) {
|
|
748
748
|
throw this.error('InvalidFunction', { functionName: functionName });
|
|
@@ -755,11 +755,11 @@ module.exports = {
|
|
|
755
755
|
externalCall: async function (callContext, connection, functionName, values) {
|
|
756
756
|
if (connection.type === 'Microservice' || connection.type === 'RestApi' || connection.type === 'ProcessEngine') {
|
|
757
757
|
let restMappings = _metadata['_rest_mappings'];
|
|
758
|
-
return await module.exports.callRest(connection, restMappings[connection.name], functionName, values, null, _configParameters, callContext);
|
|
758
|
+
return await module.exports.Dual.callRest(connection, restMappings[connection.name], functionName, values, null, _configParameters, callContext);
|
|
759
759
|
}
|
|
760
760
|
else if (connection.type === 'SoapApi') {
|
|
761
761
|
let soapMappings = _metadata['_soap_mappings'];
|
|
762
|
-
return await module.exports.callSoap(connection, soapMappings[connection.name], functionName, values, null, _configParameters, callContext);
|
|
762
|
+
return await module.exports.Dual.callSoap(connection, soapMappings[connection.name], functionName, values, null, _configParameters, callContext);
|
|
763
763
|
}
|
|
764
764
|
},
|
|
765
765
|
error: function (code, data, innerError) {
|
package/blz-kafka/index.js
CHANGED
|
@@ -404,7 +404,7 @@ async function startKafkaConsumers(kafkas, config, kafkaConsumers, connections,
|
|
|
404
404
|
}
|
|
405
405
|
if (kafkaErrorOptions.retryTopic && kafkaErrorOptions.retryTopic !== '') {
|
|
406
406
|
// sends message with error to retry topic
|
|
407
|
-
await module.exports.kafkaSend(connection, kafkaErrorOptions.retryTopic, [message]);
|
|
407
|
+
await module.exports.Backend.kafkaSend(connection, kafkaErrorOptions.retryTopic, [message]);
|
|
408
408
|
// marks the message as read on original topic
|
|
409
409
|
await consumer.commitOffsets([{ topic, partition, offset: (Number(message.offset) + 1).toString() }]);
|
|
410
410
|
}
|
package/blz-rds-mysql/index.js
CHANGED
|
@@ -18,26 +18,26 @@ process.on('exit', async function () {
|
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
module.exports = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
21
|
+
|
|
22
|
+
syntaxis: require("./syntaxis.json"),
|
|
23
|
+
executeProcedure,
|
|
24
|
+
executeSql: async function (connection, sql, parameters, options = {}) {
|
|
25
|
+
if (sql.indexOf("call") != -1) {
|
|
26
|
+
return await executeProcedure(connection, sql, parameters);
|
|
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")) {
|
|
32
|
+
return await executeQuery(connection, sql, parameters, options);
|
|
33
|
+
} else {
|
|
34
|
+
return await executeNonQuery(connection, sql, parameters, options);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
beginTransaction,
|
|
38
|
+
close,
|
|
39
|
+
createRdsConnection,
|
|
40
|
+
commitTransaction,
|
|
41
|
+
rollbackTransaction,
|
|
42
|
+
|
|
43
43
|
}
|
package/blz-rds-mysqlx/index.js
CHANGED
|
@@ -18,26 +18,26 @@ process.on('exit', async function () {
|
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
module.exports = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
21
|
+
|
|
22
|
+
syntaxis: require("./syntaxis.json"),
|
|
23
|
+
executeProcedure,
|
|
24
|
+
executeSql: async function (connection, sql, parameters, options = {}) {
|
|
25
|
+
if (sql.indexOf("call") != -1) {
|
|
26
|
+
return await executeProcedure(connection, sql, parameters);
|
|
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")) {
|
|
32
|
+
return await executeQuery(connection, sql, parameters, options);
|
|
33
|
+
} else {
|
|
34
|
+
return await executeNonQuery(connection, sql, parameters, options);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
beginTransaction,
|
|
38
|
+
close,
|
|
39
|
+
createRdsConnection,
|
|
40
|
+
commitTransaction,
|
|
41
|
+
rollbackTransaction
|
|
42
|
+
|
|
43
43
|
}
|
package/blz-rds-oracle/index.js
CHANGED
|
@@ -354,191 +354,191 @@ const rowsToArray = function (columns, rows) {
|
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
module.exports = {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
}
|
|
357
|
+
|
|
358
|
+
syntaxis: require('./syntaxis.json'),
|
|
359
|
+
createRdsConnection: async function (connection) {
|
|
360
|
+
try {
|
|
361
|
+
let oraPool = await getPool(connection);
|
|
362
|
+
let oraConnection = await oraPool.getConnection();
|
|
363
|
+
return oraConnection;
|
|
364
|
+
}
|
|
365
|
+
catch (err) {
|
|
366
|
+
throw err;
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
executeSql: async function (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);
|
|
374
|
+
} else {
|
|
375
|
+
return await this._executeSql(connection, sql, parameters, options);
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
_executeSql: async function (connection, sql, parameters, options) {
|
|
379
|
+
try {
|
|
380
|
+
let oraParameters = getOraParameters(parameters, options);
|
|
381
|
+
let oraOptions = getOraOptions(options)
|
|
382
|
+
let oraResult = await connection.execute(sql, oraParameters, oraOptions);
|
|
383
|
+
const result = await getResult(parameters, oraResult, options);
|
|
384
|
+
return result;
|
|
385
|
+
} catch (err) {
|
|
386
|
+
throw err
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
_executeBulkInsert: async function (connection, sql, rows, options) {
|
|
390
|
+
let autoincremental = null
|
|
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
|
|
398
397
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
398
|
+
}
|
|
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
405
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
}
|
|
406
|
+
// solve max size for string fields
|
|
407
|
+
const columnsCount = options.columns.length
|
|
408
|
+
for (let i = 0; i < columnsCount; i++) {
|
|
409
|
+
const column = options.columns[i]
|
|
410
|
+
if (column.type === 'string') {
|
|
411
|
+
column.size = rows.reduce((max, row) => { return !row[i] ? 0 : row[i].length > max ? row[i].length : max }, 0)
|
|
413
412
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
bindDefs[column.name] = bindDef
|
|
413
|
+
}
|
|
414
|
+
const bindDefs = {}
|
|
415
|
+
for (const column of options.columns) {
|
|
416
|
+
const bindDef = { type: getDbType(column.type) }
|
|
417
|
+
if (column.type === 'string') {
|
|
418
|
+
bindDef.maxSize = column.size
|
|
421
419
|
}
|
|
420
|
+
bindDefs[column.name] = bindDef
|
|
421
|
+
}
|
|
422
|
+
if (autoincremental) {
|
|
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 {
|
|
428
|
+
const result = await connection.executeMany(_sql, data, oraOptions)
|
|
422
429
|
if (autoincremental) {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
const data = rowsToArray(options.columns, rows)
|
|
427
|
-
try {
|
|
428
|
-
const result = await connection.executeMany(_sql, data, oraOptions)
|
|
429
|
-
if (autoincremental) {
|
|
430
|
-
const ids = []
|
|
431
|
-
for (const i in result.outBinds) {
|
|
432
|
-
ids.push(result.outBinds[i][autoincremental.name][0])
|
|
433
|
-
}
|
|
434
|
-
return { rowsAffected: result.rowsAffected, ids }
|
|
435
|
-
} else {
|
|
436
|
-
return { rowsAffected: result.rowsAffected }
|
|
430
|
+
const ids = []
|
|
431
|
+
for (const i in result.outBinds) {
|
|
432
|
+
ids.push(result.outBinds[i][autoincremental.name][0])
|
|
437
433
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
434
|
+
return { rowsAffected: result.rowsAffected, ids }
|
|
435
|
+
} else {
|
|
436
|
+
return { rowsAffected: result.rowsAffected }
|
|
441
437
|
}
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
438
|
+
} catch (err) {
|
|
439
|
+
console.log(err)
|
|
440
|
+
throw err
|
|
441
|
+
}
|
|
442
|
+
},
|
|
443
|
+
_executeBulkMerge: async function (connection, sql, rows, options) {
|
|
444
|
+
// example: https://stackoverflow.com/questions/67881781/how-to-execute-multiple-merge-into-query-on-oracle-db-from-node-js
|
|
445
|
+
let autoincremental = null
|
|
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
|
|
453
452
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
453
|
+
}
|
|
454
|
+
const _sql = []
|
|
455
|
+
_sql.push('MERGE INTO ' + options.rdsTable.tableName + ' t USING (')
|
|
456
|
+
_sql.push('SELECT ')
|
|
457
|
+
let first = true
|
|
458
|
+
for (const column of options.columns) {
|
|
459
|
+
_sql.push((first ? '' : ', ') + ':' + column.name + ' AS ' + column.name)
|
|
460
|
+
first = false
|
|
461
|
+
}
|
|
462
|
+
_sql.push('FROM DUAL')
|
|
463
|
+
_sql.push(') s ON (')
|
|
464
|
+
first = true
|
|
465
|
+
for (const field of options.mergeFields) {
|
|
466
|
+
_sql.push((first ? '' : ' AND ') + 't.' + field + ' = s.' + field)
|
|
467
|
+
first = false
|
|
468
|
+
}
|
|
469
|
+
_sql.push(')')
|
|
470
|
+
_sql.push('WHEN MATCHED THEN UPDATE SET ')
|
|
471
|
+
first = true
|
|
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)
|
|
475
|
+
first = false
|
|
476
|
+
}
|
|
477
|
+
_sql.push('WHEN NOT MATCHED THEN INSERT (')
|
|
478
|
+
if (autoincremental) {
|
|
479
|
+
_sql.push(autoincremental.name)
|
|
458
480
|
for (const column of options.columns) {
|
|
459
|
-
_sql.push(
|
|
460
|
-
|
|
481
|
+
_sql.push(',' + column.name)
|
|
482
|
+
}
|
|
483
|
+
_sql.push(') VALUES (')
|
|
484
|
+
_sql.push(autoincremental.sequence + '.NEXTVAL')
|
|
485
|
+
for (const column of options.columns) {
|
|
486
|
+
_sql.push(',s.' + column.name)
|
|
461
487
|
}
|
|
462
|
-
|
|
463
|
-
_sql.push(') s ON (')
|
|
488
|
+
} else {
|
|
464
489
|
first = true
|
|
465
|
-
for (const
|
|
466
|
-
_sql.push((first ? '' : '
|
|
490
|
+
for (const column of options.columns) {
|
|
491
|
+
_sql.push((first ? '' : ',') + column.name)
|
|
467
492
|
first = false
|
|
468
493
|
}
|
|
469
|
-
_sql.push(')')
|
|
470
|
-
_sql.push('WHEN MATCHED THEN UPDATE SET ')
|
|
494
|
+
_sql.push(') VALUES (')
|
|
471
495
|
first = true
|
|
472
496
|
for (const column of options.columns) {
|
|
473
|
-
|
|
474
|
-
_sql.push((first ? '' : ',') + 't.' + column.name + ' = s.' + column.name)
|
|
497
|
+
_sql.push((first ? '' : ',') + 's.' + column.name)
|
|
475
498
|
first = false
|
|
476
499
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
for (const column of options.columns) {
|
|
481
|
-
_sql.push(',' + column.name)
|
|
482
|
-
}
|
|
483
|
-
_sql.push(') VALUES (')
|
|
484
|
-
_sql.push(autoincremental.sequence + '.NEXTVAL')
|
|
485
|
-
for (const column of options.columns) {
|
|
486
|
-
_sql.push(',s.' + column.name)
|
|
487
|
-
}
|
|
488
|
-
} else {
|
|
489
|
-
first = true
|
|
490
|
-
for (const column of options.columns) {
|
|
491
|
-
_sql.push((first ? '' : ',') + column.name)
|
|
492
|
-
first = false
|
|
493
|
-
}
|
|
494
|
-
_sql.push(') VALUES (')
|
|
495
|
-
first = true
|
|
496
|
-
for (const column of options.columns) {
|
|
497
|
-
_sql.push((first ? '' : ',') + 's.' + column.name)
|
|
498
|
-
first = false
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
_sql.push(')')
|
|
502
|
-
const mergeSql = _sql.join(' ')
|
|
500
|
+
}
|
|
501
|
+
_sql.push(')')
|
|
502
|
+
const mergeSql = _sql.join(' ')
|
|
503
503
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
const bindDefs = {}
|
|
513
|
-
for (const column of options.columns) {
|
|
514
|
-
const bindDef = { type: getDbType(column.type) }
|
|
515
|
-
if (column.type === 'string') {
|
|
516
|
-
bindDef.maxSize = column.size
|
|
517
|
-
}
|
|
518
|
-
bindDefs[column.name] = bindDef
|
|
504
|
+
// solve max size for string fields
|
|
505
|
+
const columnsCount = options.columns.length
|
|
506
|
+
for (let i = 0; i < columnsCount; i++) {
|
|
507
|
+
const column = options.columns[i]
|
|
508
|
+
if (column.type === 'string') {
|
|
509
|
+
column.size = rows.reduce((max, row) => { return !row[i] ? 0 : row[i].length > max ? row[i].length : max }, 0)
|
|
519
510
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
console.log(err)
|
|
527
|
-
throw err
|
|
511
|
+
}
|
|
512
|
+
const bindDefs = {}
|
|
513
|
+
for (const column of options.columns) {
|
|
514
|
+
const bindDef = { type: getDbType(column.type) }
|
|
515
|
+
if (column.type === 'string') {
|
|
516
|
+
bindDef.maxSize = column.size
|
|
528
517
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
rollbackTransaction(nativeConnection) {
|
|
540
|
-
return nativeConnection.rollback();
|
|
518
|
+
bindDefs[column.name] = bindDef
|
|
519
|
+
}
|
|
520
|
+
const oraOptions = getOraOptions(options, bindDefs)
|
|
521
|
+
const data = rowsToArray(options.columns, rows)
|
|
522
|
+
try {
|
|
523
|
+
const result = await connection.executeMany(mergeSql, data, oraOptions)
|
|
524
|
+
return { rowsAffected: result.rowsAffected }
|
|
525
|
+
} catch (err) {
|
|
526
|
+
console.log(err)
|
|
527
|
+
throw err
|
|
541
528
|
}
|
|
529
|
+
},
|
|
530
|
+
close(nativeConnection) {
|
|
531
|
+
return nativeConnection.close();
|
|
532
|
+
},
|
|
533
|
+
beginTransaction(nativeConnection) {
|
|
534
|
+
//se utiliza la variable isTransactionRequest
|
|
535
|
+
},
|
|
536
|
+
commitTransaction(nativeConnection) {
|
|
537
|
+
return nativeConnection.commit();
|
|
538
|
+
},
|
|
539
|
+
rollbackTransaction(nativeConnection) {
|
|
540
|
+
return nativeConnection.rollback();
|
|
542
541
|
}
|
|
543
542
|
|
|
543
|
+
|
|
544
544
|
};
|
|
@@ -18,26 +18,26 @@ process.on('exit', async function () {
|
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
module.exports = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
21
|
+
|
|
22
|
+
syntaxis: require('./syntaxis.json'),
|
|
23
|
+
executeProcedure,
|
|
24
|
+
executeSql: async function (connection, sql, parameters, options = {}) {
|
|
25
|
+
if (sql.indexOf("call") != -1) {
|
|
26
|
+
return await executeProcedure(connection, sql, parameters);
|
|
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")) {
|
|
32
|
+
return await executeQuery(connection, sql, parameters, options);
|
|
33
|
+
} else {
|
|
34
|
+
return await executeNonQuery(connection, sql, parameters, options);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
beginTransaction,
|
|
38
|
+
close,
|
|
39
|
+
createRdsConnection,
|
|
40
|
+
commitTransaction,
|
|
41
|
+
rollbackTransaction
|
|
42
|
+
|
|
43
43
|
}
|