Skip to content

Commit

Permalink
fix db scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
allanchau committed Oct 7, 2024
1 parent ecd9635 commit ed4c5f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 7 additions & 1 deletion bin/c-mongo-download-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ const volumeName = ({ collection, env, name }) => {
(async () => {
const [, , env, collection] = process.argv;
const details = await loadConfig(`mongo.${env}`);
const connection = connectionParts(details);
const params = [...(details.params || [])];

if (collection) {
params.push(`-c=${collection}`);
}

const connection = connectionParts({ ...details, params });
const dockerVolumeName = volumeName({
collection,
env,
Expand Down
8 changes: 4 additions & 4 deletions bin/c-mongo-import-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const connectionStringWithHost = ({ auth, host, name, params }) => {
cmd.push(params);
}

return [...cmd, '--host', host, '-d', name].join(' ');
return [...cmd, '--host', host].join(' ');
};

(async () => {
Expand All @@ -47,8 +47,8 @@ const connectionStringWithHost = ({ auth, host, name, params }) => {

const collectionArg =
collection === ''
? `--nsInclude '${fromDb.name}.*' --nsFrom '${fromDb.name}.*' --nsTo '${toDb.name}.*'`
: `--nsInclude '${fromDb.name}.${collection}' --nsFrom '${fromDb.name}.*' --nsTo '${toDb.name}.*'`;
? `--nsInclude ${fromDb.name}.* --nsFrom '${fromDb.name}.*' --nsTo '${toDb.name}.*'`
: `--nsInclude ${fromDb.name}.${collection} --nsFrom '${fromDb.name}.*' --nsTo '${toDb.name}.*'`;

const args = [
'-it',
Expand All @@ -73,7 +73,7 @@ const connectionStringWithHost = ({ auth, host, name, params }) => {
? connectionStringWithHost(toDbConnection)
: connectionStringWithAddress(toDbConnection),
collectionArg,
`data/${fromDb.name}`
'data/'
);

console.log(
Expand Down

0 comments on commit ed4c5f4

Please sign in to comment.