mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 16:36:00 +00:00
ability to create string mongo IDs when importing
This commit is contained in:
@@ -14,12 +14,13 @@
|
||||
import { findFileFormat, getFileFormatDirections } from '../plugins/fileformats';
|
||||
import SqlEditor from '../query/SqlEditor.svelte';
|
||||
import { currentArchive, currentDatabase, extensions } from '../stores';
|
||||
import { useArchiveFiles, useDatabaseInfo } from '../utility/metadataLoaders';
|
||||
import { useArchiveFiles, useConnectionInfo, useDatabaseInfo } from '../utility/metadataLoaders';
|
||||
import FilesInput from './FilesInput.svelte';
|
||||
import FormConnectionSelect from './FormConnectionSelect.svelte';
|
||||
import FormDatabaseSelect from './FormDatabaseSelect.svelte';
|
||||
import FormSchemaSelect from './FormSchemaSelect.svelte';
|
||||
import FormTablesSelect from './FormTablesSelect.svelte';
|
||||
import { findEngineDriver } from 'dbgate-tools';
|
||||
|
||||
export let direction;
|
||||
export let storageTypeField;
|
||||
@@ -52,6 +53,8 @@
|
||||
$: dbinfo = useDatabaseInfo({ conid: $values[connectionIdField], database: $values[databaseNameField] });
|
||||
$: archiveFiles = useArchiveFiles({ folder: $values[archiveFolderField] });
|
||||
$: format = findFileFormat($extensions, storageType);
|
||||
$: connectionInfo = useConnectionInfo({ conid: $values[connectionIdField] });
|
||||
$: driver = findEngineDriver($connectionInfo, $extensions);
|
||||
</script>
|
||||
|
||||
<div class="column">
|
||||
@@ -159,12 +162,20 @@
|
||||
<FilesInput {setPreviewSource} />
|
||||
{/if}
|
||||
|
||||
{#if format && format.args}
|
||||
{#if format?.args}
|
||||
<FormArgumentList
|
||||
args={format.args.filter(arg => !arg.direction || arg.direction == direction)}
|
||||
namePrefix={`${direction}_${format.storageType}_`}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if driver?.importExportArgs}
|
||||
<FormArgumentList
|
||||
args={driver?.importExportArgs.filter(arg => !arg.direction || arg.direction == direction)}
|
||||
namePrefix={`${direction}_${driver.engine}_`}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -17,7 +17,7 @@ export function getTargetName(extensions, source, values) {
|
||||
return source;
|
||||
}
|
||||
|
||||
function extractApiParameters(values, direction, format) {
|
||||
function extractFormatApiParameters(values, direction, format) {
|
||||
const pairs = (format.args || [])
|
||||
.filter(arg => arg.apiName)
|
||||
.map(arg => [arg.apiName, values[`${direction}_${format.storageType}_${arg.name}`]])
|
||||
@@ -25,6 +25,14 @@ function extractApiParameters(values, direction, format) {
|
||||
return _.fromPairs(pairs);
|
||||
}
|
||||
|
||||
function extractDriverApiParameters(values, direction, driver) {
|
||||
const pairs = (driver.importExportArgs || [])
|
||||
.filter(arg => arg.apiName)
|
||||
.map(arg => [arg.apiName, values[`${direction}_${driver.engine}_${arg.name}`]])
|
||||
.filter(x => x[1] != null);
|
||||
return _.fromPairs(pairs);
|
||||
}
|
||||
|
||||
async function getConnection(extensions, storageType, conid, database) {
|
||||
if (storageType == 'database' || storageType == 'query') {
|
||||
const conn = await getConnectionInfo({ conid });
|
||||
@@ -48,6 +56,7 @@ function getSourceExpr(extensions, sourceName, values, sourceConnection, sourceD
|
||||
'tableReader',
|
||||
{
|
||||
connection: sourceConnection,
|
||||
...extractDriverApiParameters(values, 'source', sourceDriver),
|
||||
...fullName,
|
||||
},
|
||||
];
|
||||
@@ -57,6 +66,7 @@ function getSourceExpr(extensions, sourceName, values, sourceConnection, sourceD
|
||||
'queryReader',
|
||||
{
|
||||
connection: sourceConnection,
|
||||
...extractDriverApiParameters(values, 'source', sourceDriver),
|
||||
sql: values.sourceSql,
|
||||
},
|
||||
];
|
||||
@@ -69,7 +79,7 @@ function getSourceExpr(extensions, sourceName, values, sourceConnection, sourceD
|
||||
format.readerFunc,
|
||||
{
|
||||
..._.omit(sourceFile, ['isDownload']),
|
||||
...extractApiParameters(values, 'source', format),
|
||||
...extractFormatApiParameters(values, 'source', format),
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -121,7 +131,7 @@ function getTargetExpr(extensions, sourceName, values, targetConnection, targetD
|
||||
: {
|
||||
fileName: getTargetName(extensions, sourceName, values),
|
||||
}),
|
||||
...extractApiParameters(values, 'target', format),
|
||||
...extractFormatApiParameters(values, 'target', format),
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -132,6 +142,7 @@ function getTargetExpr(extensions, sourceName, values, targetConnection, targetD
|
||||
connection: targetConnection,
|
||||
schemaName: values.targetSchemaName,
|
||||
pureName: getTargetName(extensions, sourceName, values),
|
||||
...extractDriverApiParameters(values, 'target', targetDriver),
|
||||
...getFlagsFroAction(values[`actionType_${sourceName}`]),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -63,8 +63,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
// $: targetArchiveFolder = importToArchive ? `import-${moment().format('YYYY-MM-DD-hh-mm-ss')}` : $currentArchive;
|
||||
|
||||
$: effect = useEffect(() => registerRunnerDone(runnerId));
|
||||
|
||||
function registerRunnerDone(rid) {
|
||||
|
||||
Reference in New Issue
Block a user