46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
|
// @ts-check
|
||
|
|
||
|
const dbHandler = require("./dbHandler");
|
||
|
|
||
|
/**
|
||
|
* Create database from Schema Function
|
||
|
* ==============================================================================
|
||
|
* @param {string} queryString - Query String
|
||
|
* @returns {Promise<any>}
|
||
|
*/
|
||
|
module.exports = async function noDatabaseDbHandler(queryString) {
|
||
|
/**
|
||
|
* Declare variables
|
||
|
*
|
||
|
* @description Declare "results" variable
|
||
|
*/
|
||
|
let results;
|
||
|
|
||
|
/**
|
||
|
* Fetch from db
|
||
|
*
|
||
|
* @description Fetch data from db if no cache
|
||
|
*/
|
||
|
try {
|
||
|
/** ********************* Run Query */
|
||
|
results = await dbHandler({ query: queryString });
|
||
|
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
} catch (/** @type {any} */ error) {
|
||
|
console.log("ERROR in noDatabaseDbHandler =>", error.message);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Return results
|
||
|
*
|
||
|
* @description Return results add to cache if "req" param is passed
|
||
|
*/
|
||
|
if (results) {
|
||
|
return results;
|
||
|
} else {
|
||
|
return null;
|
||
|
}
|
||
|
};
|