Skip to content

Commit a052196

Browse files
committed
Adding a start-with command.
1 parent 3ba9aae commit a052196

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

commands/clone.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = function(program, next) {
1717
.option('-p, --project <project_id>', 'The project ID that you wish to clone from one database to another.')
1818
.option('--forms <forms>', 'A comma-separated value of all the Form ID\'s you wish to clone. If included, then only the provided forms will be cloned.', false)
1919
.option('--exclude <forms>', 'A comma-separated value of all the Form ID\'s you wish to exclude in the clone process.', false)
20+
.option('--start-with <form_id>', 'The form ID to start cloning from.')
2021
.option('-u, --update-existing', 'Update existing Projects and Forms instead of cloning (No OSS).', true)
2122
.option('--update-existing-submissions', 'Update existing Submissions when found in the destination (slows down the clone process if set).', false)
2223
.option('--src-ca <source_ca>', 'The TLS certificate authority for the source mongo url')

src/Cloner.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,14 +905,17 @@ class Cloner {
905905
process.stdout.write('\n');
906906
process.stdout.write(' - Forms:');
907907
let compsWithEncryptedData = [];
908+
let started = true;
909+
if (this.options.startWith) {
910+
started = false;
911+
}
908912
await this.upsertAll('forms', this.formQuery(srcProject), (form) => {
909913
process.stdout.write('\n');
910914
process.stdout.write(`- Form: ${form.title} (${form._id})`);
911915
}, async(src, update, dest) => {
912916
if (this.options.submissionsOnly) {
913917
return false;
914918
}
915-
916919
await eachComponentAsync(update.components, async(component, path) => {
917920
if (component.encrypted) {
918921
compsWithEncryptedData.push(path);
@@ -923,6 +926,12 @@ class Cloner {
923926
update.project = destProject._id;
924927
this.migrateFormAccess(src, update);
925928
}, async(srcForm, destForm) => {
929+
if (!started && this.options.startWith && srcForm._id.toString() === this.options.startWith) {
930+
started = true;
931+
}
932+
if (!started) {
933+
return false;
934+
}
926935
if (this.options.deleteSubmissions) {
927936
console.log(`Deleting submissions from ${destForm.title}`);
928937
await this.dest.submissions.deleteMany(this.itemQuery({

0 commit comments

Comments
 (0)