|
|
@@ -17,10 +17,6 @@ class ExportService {
|
|
|
this.per = 100;
|
|
|
this.zlibLevel = 9; // 0(min) - 9(max)
|
|
|
|
|
|
- // { pages: Page, users: User, ... }
|
|
|
- this.collectionMap = {};
|
|
|
- this.initCollectionMap(crowi.models);
|
|
|
-
|
|
|
// this.files = {
|
|
|
// configs: path.join(this.baseDir, 'configs.json'),
|
|
|
// pages: path.join(this.baseDir, 'pages.json'),
|
|
|
@@ -34,18 +30,6 @@ class ExportService {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * initialize collection map
|
|
|
- *
|
|
|
- * @memberOf ExportService
|
|
|
- * @param {object} models from models/index.js
|
|
|
- */
|
|
|
- initCollectionMap(models) {
|
|
|
- for (const model of Object.values(models)) {
|
|
|
- this.collectionMap[model.collection.collectionName] = model;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* parse all zip files in downloads dir
|
|
|
*
|
|
|
@@ -239,23 +223,6 @@ class ExportService {
|
|
|
return jsonFile;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * get a model from collection name
|
|
|
- *
|
|
|
- * @memberOf ExportService
|
|
|
- * @param {string} collectionName collection name
|
|
|
- * @return {object} instance of mongoose model
|
|
|
- */
|
|
|
- getModelFromCollectionName(collectionName) {
|
|
|
- const Model = this.collectionMap[collectionName];
|
|
|
-
|
|
|
- if (Model == null) {
|
|
|
- throw new Error(`cannot find a model for collection name "${collectionName}"`);
|
|
|
- }
|
|
|
-
|
|
|
- return Model;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* remove zip file from downloads dir
|
|
|
*
|