mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 06:06:01 +00:00
export/import column map support
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { TableInfo } from 'dbgate-types';
|
||||
import _cloneDeep from 'lodash/cloneDeep';
|
||||
import _fromPairs from 'lodash/fromPairs';
|
||||
import _get from 'lodash/get';
|
||||
|
||||
export function prepareTableForImport(table: TableInfo): TableInfo {
|
||||
const res = _cloneDeep(table);
|
||||
@@ -10,3 +12,12 @@ export function prepareTableForImport(table: TableInfo): TableInfo {
|
||||
if (res.primaryKey) res.primaryKey.constraintName = null;
|
||||
return res;
|
||||
}
|
||||
|
||||
interface TransformColumnDefinition {
|
||||
src: string;
|
||||
dst: string;
|
||||
}
|
||||
|
||||
export function transformRowUsingColumnMap(row, columns: TransformColumnDefinition[]) {
|
||||
return _fromPairs(columns.map(col => [col.dst, _get(row, col.src)]));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user