40 lines
1.6 KiB
JavaScript
40 lines
1.6 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.default = supplementTable;
|
|
/**
|
|
* # Supplement Table
|
|
*/
|
|
function supplementTable({ tableInfoArray }) {
|
|
/**
|
|
* Format tableInfoArray
|
|
*
|
|
* @description Format tableInfoArray
|
|
*/
|
|
let finalTableArray = tableInfoArray;
|
|
const defaultFields = require("../../../package-shared/data/defaultFields.json");
|
|
////////////////////////////////////////
|
|
let primaryKeyExists = finalTableArray.filter((_field) => _field.primaryKey);
|
|
////////////////////////////////////////
|
|
defaultFields.forEach((field) => {
|
|
let fieldExists = finalTableArray.filter((_field) => _field.fieldName === field.fieldName);
|
|
if (fieldExists && fieldExists[0]) {
|
|
return;
|
|
}
|
|
else if (field.fieldName === "id" && !primaryKeyExists[0]) {
|
|
finalTableArray.unshift(field);
|
|
}
|
|
else {
|
|
finalTableArray.push(field);
|
|
}
|
|
});
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
return finalTableArray;
|
|
}
|
|
/** ****************************************************************************** */
|
|
/** ****************************************************************************** */
|
|
/** ****************************************************************************** */
|
|
/** ****************************************************************************** */
|
|
/** ****************************************************************************** */
|