This commit is contained in:
Benjamin Toby
2024-12-06 12:55:03 +01:00
parent 34868ee0cf
commit 8a8257d17e
48 changed files with 360 additions and 221 deletions
+3 -1
View File
@@ -19,10 +19,11 @@ export = addDbEntry;
* @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 {boolean} [params.useLocal]
*
* @returns {Promise<any>}
*/
declare function addDbEntry({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, duplicateColumnName, duplicateColumnValue, update, encryptionKey, encryptionSalt, }: {
declare function addDbEntry({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, duplicateColumnName, duplicateColumnValue, update, encryptionKey, encryptionSalt, useLocal, }: {
dbContext?: ("Master" | "Dsql User");
paradigm?: ("Read Only" | "Full Access");
dbFullName?: string;
@@ -34,4 +35,5 @@ declare function addDbEntry({ dbContext, paradigm, dbFullName, tableName, data,
update?: boolean;
encryptionKey?: string;
encryptionSalt?: string;
useLocal?: boolean;
}): Promise<any>;
@@ -8,6 +8,7 @@ const _ = require("lodash");
const DB_HANDLER = require("../../../utils/backend/global-db/DB_HANDLER");
const DSQL_USER_DB_HANDLER = require("../../../utils/backend/global-db/DSQL_USER_DB_HANDLER");
const encrypt = require("../../dsql/encrypt");
const LOCAL_DB_HANDLER = require("../../../utils/backend/global-db/LOCAL_DB_HANDLER");
/**
* Add a db Entry Function
@@ -29,6 +30,7 @@ const encrypt = require("../../dsql/encrypt");
* @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 {boolean} [params.useLocal]
*
* @returns {Promise<any>}
*/
@@ -44,6 +46,7 @@ async function addDbEntry({
update,
encryptionKey,
encryptionSalt,
useLocal,
}) {
/**
* Initialize variables
@@ -55,7 +58,11 @@ async function addDbEntry({
: true;
/** @type { any } */
const dbHandler = isMaster ? DB_HANDLER : DSQL_USER_DB_HANDLER;
const dbHandler = useLocal
? LOCAL_DB_HANDLER
: isMaster
? DB_HANDLER
: DSQL_USER_DB_HANDLER;
////////////////////////////////////////
////////////////////////////////////////
+3 -1
View File
@@ -18,10 +18,11 @@ export = deleteDbEntry;
* @param {import("../../../types").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 {boolean} [params.useLocal]
*
* @returns {Promise<object|null>}
*/
declare function deleteDbEntry({ dbContext, paradigm, dbFullName, tableName, identifierColumnName, identifierValue, }: {
declare function deleteDbEntry({ dbContext, paradigm, dbFullName, tableName, identifierColumnName, identifierValue, useLocal, }: {
dbContext?: string;
paradigm?: ("Read Only" | "Full Access");
dbFullName: string;
@@ -29,4 +30,5 @@ declare function deleteDbEntry({ dbContext, paradigm, dbFullName, tableName, ide
tableSchema?: import("../../../types").DSQL_TableSchemaType;
identifierColumnName: string;
identifierValue: string | number;
useLocal?: boolean;
}): Promise<object | null>;
@@ -2,6 +2,7 @@
const DB_HANDLER = require("../../../utils/backend/global-db/DB_HANDLER");
const DSQL_USER_DB_HANDLER = require("../../../utils/backend/global-db/DSQL_USER_DB_HANDLER");
const LOCAL_DB_HANDLER = require("../../../utils/backend/global-db/LOCAL_DB_HANDLER");
/**
* Imports: Handle imports
@@ -23,6 +24,7 @@ const DSQL_USER_DB_HANDLER = require("../../../utils/backend/global-db/DSQL_USER
* @param {import("../../../types").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 {boolean} [params.useLocal]
*
* @returns {Promise<object|null>}
*/
@@ -33,6 +35,7 @@ async function deleteDbEntry({
tableName,
identifierColumnName,
identifierValue,
useLocal,
}) {
try {
/**
@@ -45,7 +48,11 @@ async function deleteDbEntry({
: true;
/** @type { (a1:any, a2?:any) => any } */
const dbHandler = isMaster ? DB_HANDLER : DSQL_USER_DB_HANDLER;
const dbHandler = useLocal
? LOCAL_DB_HANDLER
: isMaster
? DB_HANDLER
: DSQL_USER_DB_HANDLER;
////////////////////////////////////////
////////////////////////////////////////
@@ -107,6 +107,8 @@ async function runQuery({
}
if (local) {
console.log("Using Local ...");
const rawResults = await LOCAL_DB_HANDLER(
formattedQuery,
queryValuesArray
+3 -1
View File
@@ -18,10 +18,11 @@ export = updateDbEntry;
* @param {import("../../../types").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 {boolean} [params.useLocal]
*
* @returns {Promise<object|null>}
*/
declare function updateDbEntry({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, }: {
declare function updateDbEntry({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, useLocal, }: {
dbContext?: ("Master" | "Dsql User");
paradigm?: ("Read Only" | "Full Access");
dbFullName?: string;
@@ -32,4 +33,5 @@ declare function updateDbEntry({ dbContext, paradigm, dbFullName, tableName, dat
tableSchema?: import("../../../types").DSQL_TableSchemaType;
identifierColumnName: string;
identifierValue: string | number;
useLocal?: boolean;
}): Promise<object | null>;
@@ -8,6 +8,7 @@ const sanitizeHtmlOptions = require("../html/sanitizeHtmlOptions");
const DB_HANDLER = require("../../../utils/backend/global-db/DB_HANDLER");
const DSQL_USER_DB_HANDLER = require("../../../utils/backend/global-db/DSQL_USER_DB_HANDLER");
const encrypt = require("../../dsql/encrypt");
const LOCAL_DB_HANDLER = require("../../../utils/backend/global-db/LOCAL_DB_HANDLER");
/**
* Update DB Function
@@ -28,6 +29,7 @@ const encrypt = require("../../dsql/encrypt");
* @param {import("../../../types").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 {boolean} [params.useLocal]
*
* @returns {Promise<object|null>}
*/
@@ -42,6 +44,7 @@ async function updateDbEntry({
identifierValue,
encryptionKey,
encryptionSalt,
useLocal,
}) {
/**
* Check if data is valid
@@ -55,7 +58,11 @@ async function updateDbEntry({
: true;
/** @type {(a1:any, a2?:any)=> any } */
const dbHandler = isMaster ? DB_HANDLER : DSQL_USER_DB_HANDLER;
const dbHandler = useLocal
? LOCAL_DB_HANDLER
: isMaster
? DB_HANDLER
: DSQL_USER_DB_HANDLER;
////////////////////////////////////////
////////////////////////////////////////