@ccci/micro-server 1.0.66 → 1.0.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +18 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -113604,20 +113604,26 @@ class DatabaseConnector {
|
|
|
113604
113604
|
});
|
|
113605
113605
|
}
|
|
113606
113606
|
async initializeModels() {
|
|
113607
|
-
|
|
113608
|
-
|
|
113609
|
-
let
|
|
113610
|
-
|
|
113611
|
-
|
|
113612
|
-
|
|
113613
|
-
|
|
113607
|
+
try {
|
|
113608
|
+
let files = fs.readdirSync(`${DatabaseConnector.rootDir}/models`).filter((file) => file.indexOf(".") !== 0 && file.slice(-3) === ".ts");
|
|
113609
|
+
for (let i = 0;i < files.length; i++) {
|
|
113610
|
+
let file = files[i];
|
|
113611
|
+
await import(`${DatabaseConnector.rootDir}/models/${file}`).then((model2) => {
|
|
113612
|
+
console.log("Initializing Model :>> ", model2);
|
|
113613
|
+
if (model2 && model2.default && model2.default.associate) {
|
|
113614
|
+
model2.default.associate();
|
|
113615
|
+
}
|
|
113616
|
+
});
|
|
113617
|
+
}
|
|
113618
|
+
let model = DatabaseConnector.connection.models["Chats"];
|
|
113619
|
+
model.sync({ force: true }).then((res) => {
|
|
113620
|
+
console.log("Sync Result:", res);
|
|
113621
|
+
}).catch((err) => {
|
|
113622
|
+
console.log("Sync Error:", err);
|
|
113614
113623
|
});
|
|
113624
|
+
} catch (error) {
|
|
113625
|
+
console.log(error);
|
|
113615
113626
|
}
|
|
113616
|
-
DatabaseConnector.connection.models["Chats"].sync({ force: true }).then((res) => {
|
|
113617
|
-
console.log("Sync Result:", res);
|
|
113618
|
-
}).catch((err) => {
|
|
113619
|
-
console.log("Sync Error:", err);
|
|
113620
|
-
});
|
|
113621
113627
|
}
|
|
113622
113628
|
getConnections() {
|
|
113623
113629
|
return DatabaseConnector.connections.length > 0 ? DatabaseConnector.connections : [DatabaseConnector.connection];
|