mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 11:16:01 +00:00
default checked columns
This commit is contained in:
19
packages/datalib/src/getPerspectiveDefaultColumns.ts
Normal file
19
packages/datalib/src/getPerspectiveDefaultColumns.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { DatabaseInfo, TableInfo } from 'dbgate-types';
|
||||
|
||||
export function getPerspectiveDefaultColumns(table: TableInfo, db: DatabaseInfo): string[] {
|
||||
const columns = table.columns.map(x => x.columnName);
|
||||
const predicates = [
|
||||
x => x.toLowerCase() == 'name',
|
||||
x => x.toLowerCase() == 'title',
|
||||
x => x.toLowerCase().includes('name'),
|
||||
x => x.toLowerCase().includes('title'),
|
||||
x => x.dataType?.toLowerCase()?.includes('char'),
|
||||
];
|
||||
|
||||
for (const predicate of predicates) {
|
||||
const col = columns.find(predicate);
|
||||
if (col) return [col];
|
||||
}
|
||||
|
||||
return [columns[0]];
|
||||
}
|
||||
Reference in New Issue
Block a user