Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
20 lines
684 B
Plaintext
20 lines
684 B
Plaintext
import { alias } from 'drizzle-orm/pg-core';
|
|
import { alias as aliasSQLite } from 'drizzle-orm/sqlite-core/alias';
|
|
import toSnakeCase from 'to-snake-case';
|
|
import { v4 as uuid } from 'uuid';
|
|
export const getTableAlias = ({ adapter, tableName })=>{
|
|
const newAliasTableName = toSnakeCase(uuid());
|
|
let newAliasTable;
|
|
if (adapter.name === 'postgres') {
|
|
newAliasTable = alias(adapter.tables[tableName], newAliasTableName);
|
|
}
|
|
if (adapter.name === 'sqlite') {
|
|
newAliasTable = aliasSQLite(adapter.tables[tableName], newAliasTableName);
|
|
}
|
|
return {
|
|
newAliasTable,
|
|
newAliasTableName
|
|
};
|
|
};
|
|
|
|
//# sourceMappingURL=getTableAlias.js.map |