This commit is contained in:
Tben
2023-07-07 20:13:13 +01:00
parent b43eb1f990
commit cdcb3069c3
17 changed files with 82 additions and 34 deletions
+11 -2
View File
@@ -30,7 +30,7 @@ const updateDb = require("./updateDb");
*
* @returns {Promise<object|null>}
*/
module.exports = async function add({ dbFullName, tableName, data, tableSchema, duplicateColumnName, duplicateColumnValue, update, dbHost, dbPassword, dbUsername, encryptionKey, encryptionSalt }) {
async function addDb({ dbFullName, tableName, data, tableSchema, duplicateColumnName, duplicateColumnValue, update, dbHost, dbPassword, dbUsername, encryptionKey, encryptionSalt }) {
/**
* Initialize variables
*/
@@ -133,6 +133,9 @@ module.exports = async function add({ dbFullName, tableName, data, tableSchema,
const query = `INSERT INTO \`${tableName}\` (${insertKeysArray.join(",")}) VALUES (${insertValuesArray.map(() => "?").join(",")})`;
const queryValuesArray = insertValuesArray;
console.log("DSQL: Query =>", query);
console.log("DSQL: Query Values =>", queryValuesArray);
const newInsert = await handler({
queryString: query,
database: dbFullName,
@@ -153,4 +156,10 @@ module.exports = async function add({ dbFullName, tableName, data, tableSchema,
* Return statement
*/
return newInsert;
};
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
module.exports = addDb;
+8 -2
View File
@@ -24,7 +24,7 @@ const handler = require("../utils/handler");
*
* @returns {Promise<object|null>}
*/
module.exports = async function deleteDb({ dbFullName, tableName, identifierColumnName, identifierValue, dbHost, dbPassword, dbUsername, encryptionKey, encryptionSalt }) {
async function deleteDb({ dbFullName, tableName, identifierColumnName, identifierValue, dbHost, dbPassword, dbUsername, encryptionKey, encryptionSalt }) {
try {
/**
* Check if data is valid
@@ -71,4 +71,10 @@ module.exports = async function deleteDb({ dbFullName, tableName, identifierColu
return null;
}
};
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
module.exports = deleteDb;
+8 -2
View File
@@ -19,7 +19,7 @@ const handler = require("../utils/handler");
*
* @returns {Promise<object|null>}
*/
module.exports = async function query({ dbFullName, dbHost, dbPassword, dbUsername, query }) {
async function query({ dbFullName, dbHost, dbPassword, dbUsername, query }) {
/**
* Initialize variables
*/
@@ -74,4 +74,10 @@ module.exports = async function query({ dbFullName, dbHost, dbPassword, dbUserna
console.log("\x1b[31mDSQL RAW Database Handler No results returned\x1b[0m =>", results);
return null;
}
};
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
module.exports = query;
+8 -2
View File
@@ -25,7 +25,7 @@ const handler = require("../utils/handler");
*
* @returns {Promise<object|null>}
*/
module.exports = async function updateDb({ dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, dbHost, dbPassword, dbUsername, encryptionKey, encryptionSalt }) {
async function updateDb({ dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, dbHost, dbPassword, dbUsername, encryptionKey, encryptionSalt }) {
/**
* Check if data is valid
*/
@@ -89,4 +89,10 @@ module.exports = async function updateDb({ dbFullName, tableName, data, tableSch
* Return statement
*/
return updatedEntry;
};
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
module.exports = updateDb;
+2 -2
View File
@@ -2,7 +2,7 @@
* Imports
* ===================================
*/
const add = require("./db/add");
const addDb = require("./db/addDb");
const query = require("./db/query");
const update = require("./db/updateDb");
const deleteDb = require("./db/deleteDb");
@@ -16,7 +16,7 @@ const deleteDb = require("./db/deleteDb");
* ===================================
*/
const db = {
add: add,
add: addDb,
update: update,
delete: deleteDb,
query: query,