Remove all 'useLocal' params
This commit is contained in:
@@ -6,7 +6,6 @@ type Param = {
|
||||
priviledge: string;
|
||||
email: string;
|
||||
};
|
||||
useLocal?: boolean;
|
||||
user: DATASQUIREL_LoggedInUser;
|
||||
};
|
||||
/**
|
||||
@@ -17,5 +16,5 @@ type Param = {
|
||||
* admin user. This fires when the invited user has been logged in or a new account
|
||||
* has been created for the invited user
|
||||
*/
|
||||
export default function addAdminUserOnLogin({ query, user, useLocal, }: Param): Promise<any>;
|
||||
export default function addAdminUserOnLogin({ query, user, }: Param): Promise<any>;
|
||||
export {};
|
||||
|
||||
@@ -26,9 +26,11 @@ const LOCAL_DB_HANDLER_1 = __importDefault(require("../../utils/backend/global-d
|
||||
* has been created for the invited user
|
||||
*/
|
||||
function addAdminUserOnLogin(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ query, user, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ query, user, }) {
|
||||
try {
|
||||
const finalDbHandler = useLocal ? LOCAL_DB_HANDLER_1.default : DB_HANDLER_1.default;
|
||||
const finalDbHandler = global.DSQL_USE_LOCAL
|
||||
? LOCAL_DB_HANDLER_1.default
|
||||
: DB_HANDLER_1.default;
|
||||
const { invite, database_access, priviledge, email } = query;
|
||||
const lastInviteTimeQuery = `SELECT date_created_code FROM invitations WHERE inviting_user_id=? AND invited_user_email=?`;
|
||||
const lastInviteTimeValues = [invite, email];
|
||||
@@ -65,7 +67,6 @@ function addAdminUserOnLogin(_a) {
|
||||
image: user.image,
|
||||
image_thumbnail: user.image_thumbnail,
|
||||
},
|
||||
useLocal,
|
||||
});
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
@@ -91,7 +92,6 @@ function addAdminUserOnLogin(_a) {
|
||||
table: table_slug,
|
||||
priviledge: priviledge,
|
||||
},
|
||||
useLocal,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
type Param = {
|
||||
userId: number | string;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Add Mariadb User
|
||||
*/
|
||||
export default function addMariadbUser({ userId, useLocal, }: Param): Promise<any>;
|
||||
export default function addMariadbUser({ userId }: Param): Promise<any>;
|
||||
export {};
|
||||
|
||||
+3
-4
@@ -23,7 +23,7 @@ const LOCAL_DB_HANDLER_1 = __importDefault(require("../../utils/backend/global-d
|
||||
* # Add Mariadb User
|
||||
*/
|
||||
function addMariadbUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ userId, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ userId }) {
|
||||
try {
|
||||
const defaultMariadbUserHost = process.env.DSQL_DB_HOST || "127.0.0.1";
|
||||
const username = `dsql_user_${userId}`;
|
||||
@@ -36,7 +36,7 @@ function addMariadbUser(_a) {
|
||||
});
|
||||
const encryptedPassword = (0, encrypt_1.default)({ data: password });
|
||||
const createMariadbUsersQuery = `CREATE USER IF NOT EXISTS '${username}'@'127.0.0.1' IDENTIFIED BY '${password}'`;
|
||||
if (useLocal) {
|
||||
if (global.DSQL_USE_LOCAL) {
|
||||
yield (0, LOCAL_DB_HANDLER_1.default)(createMariadbUsersQuery);
|
||||
}
|
||||
else {
|
||||
@@ -44,7 +44,7 @@ function addMariadbUser(_a) {
|
||||
}
|
||||
const updateUserQuery = `UPDATE users SET mariadb_user = ?, mariadb_host = '127.0.0.1', mariadb_pass = ? WHERE id = ?`;
|
||||
const updateUserValues = [username, encryptedPassword, userId];
|
||||
const updateUser = useLocal
|
||||
const updateUser = global.DSQL_USE_LOCAL
|
||||
? yield (0, LOCAL_DB_HANDLER_1.default)(updateUserQuery, updateUserValues)
|
||||
: yield (0, DB_HANDLER_1.default)(updateUserQuery, updateUserValues);
|
||||
const addMariadbUser = yield (0, addDbEntry_1.default)({
|
||||
@@ -58,7 +58,6 @@ function addMariadbUser(_a) {
|
||||
grants: '[{"database":"*","table":"*","privileges":["ALL"]}]',
|
||||
},
|
||||
dbContext: "Master",
|
||||
useLocal,
|
||||
});
|
||||
console.log(`User ${userId} SQL credentials successfully added.`);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
type Param = {
|
||||
userId: number;
|
||||
database: string;
|
||||
useLocal?: boolean;
|
||||
payload?: {
|
||||
[s: string]: any;
|
||||
};
|
||||
@@ -9,5 +8,5 @@ type Param = {
|
||||
/**
|
||||
* # Add User Table to Database
|
||||
*/
|
||||
export default function addUsersTableToDb({ userId, database, useLocal, payload, }: Param): Promise<any>;
|
||||
export default function addUsersTableToDb({ userId, database, payload, }: Param): Promise<any>;
|
||||
export {};
|
||||
|
||||
@@ -25,7 +25,7 @@ const grabNewUsersTableSchema_1 = __importDefault(require("./grabNewUsersTableSc
|
||||
* # Add User Table to Database
|
||||
*/
|
||||
function addUsersTableToDb(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ userId, database, useLocal, payload, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ userId, database, payload, }) {
|
||||
try {
|
||||
const dbFullName = database;
|
||||
const userPreset = (0, grabNewUsersTableSchema_1.default)({ payload });
|
||||
@@ -46,8 +46,7 @@ function addUsersTableToDb(_a) {
|
||||
targetDatabase.tables.push(userPreset);
|
||||
}
|
||||
(0, setUserSchemaData_1.default)({ schemaData: userSchemaData, userId });
|
||||
/** @type {any[] | null} */
|
||||
const targetDb = useLocal
|
||||
const targetDb = global.DSQL_USE_LOCAL
|
||||
? yield (0, LOCAL_DB_HANDLER_1.default)(`SELECT id FROM user_databases WHERE user_id=? AND db_slug=?`, [userId, database])
|
||||
: yield (0, DB_HANDLER_1.default)(`SELECT id FROM user_databases WHERE user_id=? AND db_slug=?`, [userId, database]);
|
||||
if (targetDb === null || targetDb === void 0 ? void 0 : targetDb[0]) {
|
||||
@@ -61,7 +60,6 @@ function addUsersTableToDb(_a) {
|
||||
table_name: "Users",
|
||||
table_slug: "users",
|
||||
},
|
||||
useLocal,
|
||||
});
|
||||
}
|
||||
const dbShellUpdate = yield (0, createDbFromSchema_1.default)({
|
||||
|
||||
+1
-23
@@ -10,31 +10,9 @@ type Param = {
|
||||
update?: boolean;
|
||||
encryptionKey?: string;
|
||||
encryptionSalt?: string;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* Add a db Entry Function
|
||||
* ==============================================================================
|
||||
* @description Description
|
||||
* @async
|
||||
*
|
||||
* @param {object} params - An object containing the function parameters.
|
||||
* @param {("Master" | "Dsql User")} [params.dbContext] - What is the database context? "Master"
|
||||
* or "Dsql User". Defaults to "Master"
|
||||
* @param {("Read Only" | "Full Access")} [params.paradigm] - What is the paradigm for "Dsql User"?
|
||||
* "Read only" or "Full Access"? Defaults to "Read Only"
|
||||
* @param {string} [params.dbFullName] - Database full name
|
||||
* @param {string} params.tableName - Table name
|
||||
* @param {any} params.data - Data to add
|
||||
* @param {import("../../../types").DSQL_TableSchemaType} [params.tableSchema] - Table schema
|
||||
* @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 {boolean} [params.useLocal]
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export default function addDbEntry({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, duplicateColumnName, duplicateColumnValue, update, encryptionKey, encryptionSalt, useLocal, }: Param): Promise<any>;
|
||||
export default function addDbEntry({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, duplicateColumnName, duplicateColumnValue, update, encryptionKey, encryptionSalt, }: Param): Promise<any>;
|
||||
export {};
|
||||
|
||||
+3
-24
@@ -23,35 +23,14 @@ const encrypt_1 = __importDefault(require("../../dsql/encrypt"));
|
||||
const LOCAL_DB_HANDLER_1 = __importDefault(require("../../../utils/backend/global-db/LOCAL_DB_HANDLER"));
|
||||
/**
|
||||
* Add a db Entry Function
|
||||
* ==============================================================================
|
||||
* @description Description
|
||||
* @async
|
||||
*
|
||||
* @param {object} params - An object containing the function parameters.
|
||||
* @param {("Master" | "Dsql User")} [params.dbContext] - What is the database context? "Master"
|
||||
* or "Dsql User". Defaults to "Master"
|
||||
* @param {("Read Only" | "Full Access")} [params.paradigm] - What is the paradigm for "Dsql User"?
|
||||
* "Read only" or "Full Access"? Defaults to "Read Only"
|
||||
* @param {string} [params.dbFullName] - Database full name
|
||||
* @param {string} params.tableName - Table name
|
||||
* @param {any} params.data - Data to add
|
||||
* @param {import("../../../types").DSQL_TableSchemaType} [params.tableSchema] - Table schema
|
||||
* @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 {boolean} [params.useLocal]
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
function addDbEntry(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, duplicateColumnName, duplicateColumnValue, update, encryptionKey, encryptionSalt, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, duplicateColumnName, duplicateColumnValue, update, encryptionKey, encryptionSalt, }) {
|
||||
var _b, _c;
|
||||
/**
|
||||
* Initialize variables
|
||||
*/
|
||||
const isMaster = useLocal
|
||||
const isMaster = global.DSQL_USE_LOCAL
|
||||
? true
|
||||
: (dbContext === null || dbContext === void 0 ? void 0 : dbContext.match(/dsql.user/i))
|
||||
? false
|
||||
@@ -59,7 +38,7 @@ function addDbEntry(_a) {
|
||||
? false
|
||||
: true;
|
||||
/** @type { any } */
|
||||
const dbHandler = useLocal
|
||||
const dbHandler = global.DSQL_USE_LOCAL
|
||||
? LOCAL_DB_HANDLER_1.default
|
||||
: isMaster
|
||||
? DB_HANDLER_1.default
|
||||
|
||||
@@ -6,11 +6,10 @@ type Param = {
|
||||
tableSchema?: import("../../../types").DSQL_TableSchemaType;
|
||||
identifierColumnName: string;
|
||||
identifierValue: string | number;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Delete DB Entry Function
|
||||
* @description
|
||||
*/
|
||||
export default function deleteDbEntry({ dbContext, paradigm, dbFullName, tableName, identifierColumnName, identifierValue, useLocal, }: Param): Promise<object | null>;
|
||||
export default function deleteDbEntry({ dbContext, paradigm, dbFullName, tableName, identifierColumnName, identifierValue, }: Param): Promise<object | null>;
|
||||
export {};
|
||||
|
||||
@@ -21,17 +21,16 @@ const LOCAL_DB_HANDLER_1 = __importDefault(require("../../../utils/backend/globa
|
||||
* @description
|
||||
*/
|
||||
function deleteDbEntry(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbContext, paradigm, dbFullName, tableName, identifierColumnName, identifierValue, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbContext, paradigm, dbFullName, tableName, identifierColumnName, identifierValue, }) {
|
||||
try {
|
||||
const isMaster = useLocal
|
||||
const isMaster = global.DSQL_USE_LOCAL
|
||||
? true
|
||||
: (dbContext === null || dbContext === void 0 ? void 0 : dbContext.match(/dsql.user/i))
|
||||
? false
|
||||
: dbFullName && !dbFullName.match(/^datasquirel$/)
|
||||
? false
|
||||
: true;
|
||||
/** @type { (a1:any, a2?:any) => any } */
|
||||
const dbHandler = useLocal
|
||||
const dbHandler = global.DSQL_USE_LOCAL
|
||||
? LOCAL_DB_HANDLER_1.default
|
||||
: isMaster
|
||||
? DB_HANDLER_1.default
|
||||
|
||||
+1
-2
@@ -2,7 +2,6 @@ type Param = {
|
||||
dbFullName: string;
|
||||
query: string | any;
|
||||
readOnly?: boolean;
|
||||
local?: boolean;
|
||||
debug?: boolean;
|
||||
dbSchema?: import("../../../types").DSQL_DatabaseSchemaType;
|
||||
queryValuesArray?: (string | number)[];
|
||||
@@ -11,5 +10,5 @@ type Param = {
|
||||
/**
|
||||
* # Run DSQL users queries
|
||||
*/
|
||||
export default function runQuery({ dbFullName, query, readOnly, dbSchema, queryValuesArray, tableName, local, debug, }: Param): Promise<any>;
|
||||
export default function runQuery({ dbFullName, query, readOnly, dbSchema, queryValuesArray, tableName, debug, }: Param): Promise<any>;
|
||||
export {};
|
||||
|
||||
+12
-11
@@ -24,7 +24,7 @@ const trim_sql_1 = __importDefault(require("../../../utils/trim-sql"));
|
||||
* # Run DSQL users queries
|
||||
*/
|
||||
function runQuery(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbFullName, query, readOnly, dbSchema, queryValuesArray, tableName, local, debug, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbFullName, query, readOnly, dbSchema, queryValuesArray, tableName, debug, }) {
|
||||
/**
|
||||
* Declare variables
|
||||
*
|
||||
@@ -58,7 +58,7 @@ function runQuery(_a) {
|
||||
try {
|
||||
if (typeof query === "string") {
|
||||
const formattedQuery = (0, trim_sql_1.default)(query);
|
||||
if (debug && local) {
|
||||
if (debug && global.DSQL_USE_LOCAL) {
|
||||
console.log("runQuery:formattedQuery", formattedQuery);
|
||||
}
|
||||
/**
|
||||
@@ -75,7 +75,6 @@ function runQuery(_a) {
|
||||
queryString: formattedQuery,
|
||||
queryValuesArray: queryValuesArray === null || queryValuesArray === void 0 ? void 0 : queryValuesArray.map((vl) => String(vl)),
|
||||
tableSchema,
|
||||
useLocal: local,
|
||||
});
|
||||
}
|
||||
else {
|
||||
@@ -83,7 +82,6 @@ function runQuery(_a) {
|
||||
queryString: formattedQuery,
|
||||
queryValuesArray: queryValuesArray === null || queryValuesArray === void 0 ? void 0 : queryValuesArray.map((vl) => String(vl)),
|
||||
tableSchema,
|
||||
local,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -97,7 +95,9 @@ function runQuery(_a) {
|
||||
switch (action.toLowerCase()) {
|
||||
case "insert":
|
||||
result = yield (0, addDbEntry_1.default)({
|
||||
dbContext: local ? "Master" : "Dsql User",
|
||||
dbContext: global.DSQL_USE_LOCAL
|
||||
? "Master"
|
||||
: "Dsql User",
|
||||
paradigm: "Full Access",
|
||||
dbFullName: dbFullName,
|
||||
tableName: table,
|
||||
@@ -106,7 +106,6 @@ function runQuery(_a) {
|
||||
duplicateColumnName,
|
||||
duplicateColumnValue,
|
||||
tableSchema,
|
||||
useLocal: local,
|
||||
});
|
||||
if (!(result === null || result === void 0 ? void 0 : result.insertId)) {
|
||||
error = new Error("Couldn't insert data");
|
||||
@@ -114,7 +113,9 @@ function runQuery(_a) {
|
||||
break;
|
||||
case "update":
|
||||
result = yield (0, updateDbEntry_1.default)({
|
||||
dbContext: local ? "Master" : "Dsql User",
|
||||
dbContext: global.DSQL_USE_LOCAL
|
||||
? "Master"
|
||||
: "Dsql User",
|
||||
paradigm: "Full Access",
|
||||
dbFullName: dbFullName,
|
||||
tableName: table,
|
||||
@@ -122,19 +123,19 @@ function runQuery(_a) {
|
||||
identifierColumnName,
|
||||
identifierValue,
|
||||
tableSchema,
|
||||
useLocal: local,
|
||||
});
|
||||
break;
|
||||
case "delete":
|
||||
result = yield (0, deleteDbEntry_1.default)({
|
||||
dbContext: local ? "Master" : "Dsql User",
|
||||
dbContext: global.DSQL_USE_LOCAL
|
||||
? "Master"
|
||||
: "Dsql User",
|
||||
paradigm: "Full Access",
|
||||
dbFullName: dbFullName,
|
||||
tableName: table,
|
||||
identifierColumnName,
|
||||
identifierValue,
|
||||
tableSchema,
|
||||
useLocal: local,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
@@ -148,7 +149,7 @@ function runQuery(_a) {
|
||||
component: "functions/backend/runQuery",
|
||||
message: error.message,
|
||||
});
|
||||
if (debug && local) {
|
||||
if (debug && global.DSQL_USE_LOCAL) {
|
||||
console.log("runQuery:error", error.message);
|
||||
}
|
||||
result = null;
|
||||
|
||||
@@ -9,11 +9,10 @@ type Param = {
|
||||
tableSchema?: import("../../../types").DSQL_TableSchemaType;
|
||||
identifierColumnName: string;
|
||||
identifierValue: string | number;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Update DB Function
|
||||
* @description
|
||||
*/
|
||||
export default function updateDbEntry({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, useLocal, }: Param): Promise<object | null>;
|
||||
export default function updateDbEntry({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, }: Param): Promise<object | null>;
|
||||
export {};
|
||||
|
||||
@@ -24,14 +24,14 @@ const LOCAL_DB_HANDLER_1 = __importDefault(require("../../../utils/backend/globa
|
||||
* @description
|
||||
*/
|
||||
function updateDbEntry(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ dbContext, paradigm, dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, encryptionKey, encryptionSalt, }) {
|
||||
var _b;
|
||||
/**
|
||||
* Check if data is valid
|
||||
*/
|
||||
if (!data || !Object.keys(data).length)
|
||||
return null;
|
||||
const isMaster = useLocal
|
||||
const isMaster = global.DSQL_USE_LOCAL
|
||||
? true
|
||||
: (dbContext === null || dbContext === void 0 ? void 0 : dbContext.match(/dsql.user/i))
|
||||
? false
|
||||
@@ -39,7 +39,7 @@ function updateDbEntry(_a) {
|
||||
? false
|
||||
: true;
|
||||
/** @type {(a1:any, a2?:any)=> any } */
|
||||
const dbHandler = useLocal
|
||||
const dbHandler = global.DSQL_USE_LOCAL
|
||||
? LOCAL_DB_HANDLER_1.default
|
||||
: isMaster
|
||||
? DB_HANDLER_1.default
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
type Param = {
|
||||
queryString: string;
|
||||
local?: boolean;
|
||||
tableSchema?: import("../../types").DSQL_TableSchemaType | null;
|
||||
queryValuesArray?: string[];
|
||||
};
|
||||
/**
|
||||
* # Full Access Db Handler
|
||||
*/
|
||||
export default function fullAccessDbHandler({ queryString, tableSchema, queryValuesArray, local, }: Param): Promise<any>;
|
||||
export default function fullAccessDbHandler({ queryString, tableSchema, queryValuesArray, }: Param): Promise<any>;
|
||||
export {};
|
||||
|
||||
@@ -22,7 +22,7 @@ const serverError_1 = __importDefault(require("./serverError"));
|
||||
* # Full Access Db Handler
|
||||
*/
|
||||
function fullAccessDbHandler(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ queryString, tableSchema, queryValuesArray, local, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ queryString, tableSchema, queryValuesArray, }) {
|
||||
/**
|
||||
* Declare variables
|
||||
*
|
||||
@@ -36,7 +36,7 @@ function fullAccessDbHandler(_a) {
|
||||
*/
|
||||
try {
|
||||
/** ********************* Run Query */
|
||||
results = local
|
||||
results = global.DSQL_USE_LOCAL
|
||||
? yield (0, LOCAL_DB_HANDLER_1.default)(queryString, queryValuesArray)
|
||||
: yield (0, DSQL_USER_DB_HANDLER_1.default)({
|
||||
paradigm: "Full Access",
|
||||
|
||||
@@ -3,11 +3,10 @@ type Param = {
|
||||
queryValuesArray?: any[];
|
||||
database?: string;
|
||||
tableSchema?: import("../../types").DSQL_TableSchemaType;
|
||||
useLocal?: boolean;
|
||||
debug?: boolean;
|
||||
};
|
||||
/**
|
||||
* # DB handler for specific database
|
||||
*/
|
||||
export default function varDatabaseDbHandler({ queryString, queryValuesArray, database, tableSchema, useLocal, debug, }: Param): Promise<any>;
|
||||
export default function varDatabaseDbHandler({ queryString, queryValuesArray, database, tableSchema, debug, }: Param): Promise<any>;
|
||||
export {};
|
||||
|
||||
@@ -21,9 +21,9 @@ const conn_db_handler_1 = __importDefault(require("../../utils/db/conn-db-handle
|
||||
* # DB handler for specific database
|
||||
*/
|
||||
function varDatabaseDbHandler(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ queryString, queryValuesArray, database, tableSchema, useLocal, debug, }) {
|
||||
let CONNECTION = (0, grab_dsql_connection_1.default)({ fa: true, local: useLocal });
|
||||
if (useLocal)
|
||||
return __awaiter(this, arguments, void 0, function* ({ queryString, queryValuesArray, database, tableSchema, debug, }) {
|
||||
let CONNECTION = (0, grab_dsql_connection_1.default)({ fa: true });
|
||||
if (global.DSQL_USE_LOCAL)
|
||||
CONNECTION = (0, grab_dsql_connection_1.default)({ local: true });
|
||||
if (database === null || database === void 0 ? void 0 : database.match(/^datasquirel$/))
|
||||
CONNECTION = (0, grab_dsql_connection_1.default)();
|
||||
|
||||
@@ -2,11 +2,10 @@ type Param = {
|
||||
queryString: string;
|
||||
queryValuesArray?: string[];
|
||||
tableSchema?: import("../../types").DSQL_TableSchemaType;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Read Only Db Handler with Varaibles
|
||||
* @returns
|
||||
*/
|
||||
export default function varReadOnlyDatabaseDbHandler({ queryString, queryValuesArray, tableSchema, useLocal, }: Param): Promise<any>;
|
||||
export default function varReadOnlyDatabaseDbHandler({ queryString, queryValuesArray, tableSchema, }: Param): Promise<any>;
|
||||
export {};
|
||||
|
||||
@@ -23,7 +23,7 @@ const LOCAL_DB_HANDLER_1 = __importDefault(require("../../utils/backend/global-d
|
||||
* @returns
|
||||
*/
|
||||
function varReadOnlyDatabaseDbHandler(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ queryString, queryValuesArray, tableSchema, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ queryString, queryValuesArray, tableSchema, }) {
|
||||
/**
|
||||
* Declare variables
|
||||
*
|
||||
@@ -36,7 +36,7 @@ function varReadOnlyDatabaseDbHandler(_a) {
|
||||
* @description Fetch data from db if no cache
|
||||
*/
|
||||
try {
|
||||
results = useLocal
|
||||
results = global.DSQL_USE_LOCAL
|
||||
? yield (0, LOCAL_DB_HANDLER_1.default)(queryString, queryValuesArray)
|
||||
: yield (0, DSQL_USER_DB_HANDLER_1.default)({
|
||||
paradigm: "Read Only",
|
||||
|
||||
Reference in New Issue
Block a user