Yuki Takei 6 лет назад
Родитель
Сommit
cabe253b7f
1 измененных файлов с 6 добавлено и 1 удалено
  1. 6 1
      src/server/service/import.js

+ 6 - 1
src/server/service/import.js

@@ -161,11 +161,16 @@ class ImportService {
     const execUnorderedBulkOpSafely = this.execUnorderedBulkOpSafely.bind(this);
     const emitProgressEvent = this.emitProgressEvent.bind(this);
 
-    const { jsonFileName, overwriteParams } = importOptions;
+    const { mode, jsonFileName, overwriteParams } = importOptions;
     const Model = this.growiBridgeService.getModelFromCollectionName(collectionName);
     const jsonFile = this.getFile(jsonFileName);
     const collectionProgress = this.currentProgressingStatus.progressMap[collectionName];
 
+    // flush
+    if (mode === 'flushAndInsert') {
+      await Model.remove({});
+    }
+
     // stream 1
     const readStream = fs.createReadStream(jsonFile, { encoding: this.growiBridgeService.getEncoding() });