|
@@ -1,6 +1,8 @@
|
|
|
'use strict';
|
|
|
|
|
|
const async = require("async");
|
|
|
+const fs = require("fs");
|
|
|
+const path = require("path");
|
|
|
|
|
|
const coreClass = require("../core");
|
|
|
|
|
@@ -22,6 +24,8 @@ module.exports = class extends coreClass {
|
|
|
this.accountSchemaSchema = await this.mongoModule.schema("accountSchema");
|
|
|
this.accountSchemaModel = await this.mongoModule.model("accountSchema");
|
|
|
|
|
|
+ this.schemaDirectoryPath = path.join(__dirname, "..", "schemas", "account");
|
|
|
+
|
|
|
resolve();
|
|
|
})
|
|
|
}
|
|
@@ -93,6 +97,18 @@ module.exports = class extends coreClass {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ async listSchemasInDirectory() {
|
|
|
+ return new Promise(async (resolve, reject) => {
|
|
|
+ try { await this._validateHook(); } catch { return; }
|
|
|
+
|
|
|
+ fs.readdir(this.schemaDirectoryPath, (err, files) => {
|
|
|
+ if (err) reject(new Error(err.message))
|
|
|
+ else resolve(files.map(file => file.substring(0, file.length - 3)));
|
|
|
+ });
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
async import(name) {
|
|
|
return new Promise(async (resolve, reject) => {
|
|
|
try { await this._validateHook(); } catch { return; }
|