This commit is contained in:
Tben
2023-08-12 17:35:59 +01:00
parent f0feaf508b
commit b5a4de3e8f
7 changed files with 34 additions and 8 deletions
+4 -2
View File
@@ -26,8 +26,8 @@ const updateDbEntry = require("./updateDbEntry");
* @param {string} [params.duplicateColumnName] - Duplicate column name
* @param {string} [params.duplicateColumnValue] - Duplicate column value
* @param {boolean} [params.update] - Update this row if it exists
* @param {string} [params.encryptionKey] - Update this row if it exists
* @param {string} [params.encryptionSalt] - Update this row if it exists
* @param {string} params.encryptionKey - Update this row if it exists
* @param {string} params.encryptionSalt - Update this row if it exists
*
* @returns {Promise<object|null>}
*/
@@ -63,6 +63,8 @@ async function addDbEntry({ dbContext, paradigm, dbFullName, tableName, data, ta
tableSchema,
identifierColumnName: duplicateColumnName,
identifierValue: duplicateColumnValue || "",
encryptionKey,
encryptionSalt,
});
}
}
+7
View File
@@ -33,6 +33,9 @@ async function runQuery({ dbFullName, query, readOnly, dbSchema, queryValuesArra
*
* @description Declare "results" variable
*/
const encryptionKey = process.env.DSQL_ENCRYPTION_KEY || "";
const encryptionSalt = process.env.DSQL_ENCRYPTION_SALT || "";
let result, error, tableSchema;
if (dbSchema) {
@@ -78,6 +81,8 @@ async function runQuery({ dbFullName, query, readOnly, dbSchema, queryValuesArra
duplicateColumnName,
duplicateColumnValue,
tableSchema,
encryptionKey,
encryptionSalt,
});
if (!result?.insertId) {
@@ -96,6 +101,8 @@ async function runQuery({ dbFullName, query, readOnly, dbSchema, queryValuesArra
identifierColumnName,
identifierValue,
tableSchema,
encryptionKey,
encryptionSalt,
});
break;
+3 -4
View File
@@ -24,10 +24,12 @@ const dbHandler = require("../../engine/utils/dbHandler");
* @param {import("../../../types/database-schema.td").DSQL_TableSchemaType} [params.tableSchema] - Table schema
* @param {string} params.identifierColumnName - Update row identifier column name
* @param {string | number} params.identifierValue - Update row identifier column value
* @param {string} params.encryptionKey - Encryption key
* @param {string} params.encryptionSalt - Encryption salt
*
* @returns {Promise<object|null>}
*/
async function updateDbEntry({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue }) {
async function updateDbEntry({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt }) {
/**
* Check if data is valid
*/
@@ -47,9 +49,6 @@ async function updateDbEntry({ dbContext, paradigm, dbFullName, tableName, data,
let updateKeyValueArray = [];
let updateValues = [];
const encryptionKey = process.env.DSQL_ENCRYPTION_KEY;
const encryptionSalt = process.env.DSQL_ENCRYPTION_SALT;
/**
* Declare variables
*