24 lines
588 B
JavaScript
24 lines
588 B
JavaScript
/**
|
|
* # Grab Key Names
|
|
* @description Grab key names for foreign keys and indexes
|
|
*/
|
|
export default function grabSQLKeyName({ type, userId, addDate }) {
|
|
let prefixParadigm = (() => {
|
|
if (type == "foreign_key")
|
|
return "fk";
|
|
if (type == "index")
|
|
return "indx";
|
|
if (type == "user")
|
|
return "user";
|
|
return null;
|
|
})();
|
|
let key = `dsql`;
|
|
if (prefixParadigm)
|
|
key += `_${prefixParadigm}`;
|
|
if (userId)
|
|
key += `_${userId}`;
|
|
if (addDate)
|
|
key += `_${Date.now()}`;
|
|
return key;
|
|
}
|