@ccci/micro-server 1.0.66 → 1.0.68
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 +19 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -113604,20 +113604,27 @@ 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
|
+
DatabaseConnector.connection.sync({ force: true });
|
|
113619
|
+
let model = DatabaseConnector.connection.models["Chats"];
|
|
113620
|
+
model.sync({ force: true }).then((res) => {
|
|
113621
|
+
console.log("Sync Result:", res);
|
|
113622
|
+
}).catch((err) => {
|
|
113623
|
+
console.log("Sync Error:", err);
|
|
113614
113624
|
});
|
|
113625
|
+
} catch (error) {
|
|
113626
|
+
console.log(error);
|
|
113615
113627
|
}
|
|
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
113628
|
}
|
|
113622
113629
|
getConnections() {
|
|
113623
113630
|
return DatabaseConnector.connections.length > 0 ? DatabaseConnector.connections : [DatabaseConnector.connection];
|