2024-12-06 13:24:26 +00:00
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
const serverError = require("./serverError");
|
|
|
|
const fs = require("fs");
|
|
|
|
const path = require("path");
|
|
|
|
|
|
|
|
/** ****************************************************************************** */
|
|
|
|
/** ****************************************************************************** */
|
|
|
|
/** ****************************************************************************** */
|
|
|
|
/** ****************************************************************************** */
|
|
|
|
/** ****************************************************************************** */
|
|
|
|
/** ****************************************************************************** */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ==============================================================================
|
|
|
|
* @param {Object} params
|
|
|
|
* @param {string | number} params.userId
|
|
|
|
* @returns {import("../../types").DSQL_DatabaseSchemaType[] | null}
|
|
|
|
*/
|
2024-12-15 11:27:16 +00:00
|
|
|
module.exports = function grabUserSchemaData({ userId }) {
|
2024-12-06 13:24:26 +00:00
|
|
|
try {
|
|
|
|
const userSchemaFilePath = path.resolve(
|
|
|
|
process.cwd(),
|
|
|
|
`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${userId}/main.json`
|
|
|
|
);
|
|
|
|
const userSchemaData = JSON.parse(
|
|
|
|
fs.readFileSync(userSchemaFilePath, "utf-8")
|
|
|
|
);
|
|
|
|
|
|
|
|
return userSchemaData;
|
|
|
|
} catch (/** @type {any} */ error) {
|
|
|
|
serverError({
|
|
|
|
component: "grabUserSchemaData",
|
|
|
|
message: error.message,
|
|
|
|
});
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2024-12-15 11:27:16 +00:00
|
|
|
};
|
2024-12-06 13:24:26 +00:00
|
|
|
|
|
|
|
/** ****************************************************************************** */
|
|
|
|
/** ****************************************************************************** */
|
|
|
|
/** ****************************************************************************** */
|
|
|
|
/** ****************************************************************************** */
|
|
|
|
/** ****************************************************************************** */
|
|
|
|
/** ****************************************************************************** */
|