@flutry/sequelize 0.0.5 → 0.0.7

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/README.md CHANGED
@@ -1,26 +1,26 @@
1
- # @flutry/sequelize
2
-
3
- ![npm version](https://img.shields.io/npm/v/@flutry/sequelize)
4
-
5
- A fully customizable sequelize integration for Flutry projects, with automatic model loading, database connection, and support for advanced features like associations and hooks.
6
-
7
- ## 🔧 Features
8
-
9
- - 🔌 Automatically connects to the database using Flutry configuration.
10
- - 📦 Dynamically loads all sequelize models from the `models/` directory.
11
- - 🛠️ Built-in support for model synchronization.
12
- - 🔁 Integrates smoothly with the Flutry dynamic adapters system.
13
- - 🔍 Enhanced error handling and logging for development.
14
-
15
- ## Access Database Type
16
-
17
- - mysql
18
- - mariadb
19
-
20
- ## 📄 Licenc
21
-
22
- MIT
23
-
24
- ## 🌐 Website
25
-
26
- The official website of the package: [https://flutry.com/docs/package/sequelize](https://flutry.com/docs/package/sequelize)
1
+ # @flutry/sequelize
2
+
3
+ ![npm version](https://img.shields.io/npm/v/@flutry/sequelize)
4
+
5
+ A fully customizable sequelize integration for Flutry projects, with automatic model loading, database connection, and support for advanced features like associations and hooks.
6
+
7
+ ## 🔧 Features
8
+
9
+ - 🔌 Automatically connects to the database using Flutry configuration.
10
+ - 📦 Dynamically loads all sequelize models from the `models/` directory.
11
+ - 🛠️ Built-in support for model synchronization.
12
+ - 🔁 Integrates smoothly with the Flutry dynamic adapters system.
13
+ - 🔍 Enhanced error handling and logging for development.
14
+
15
+ ## Access Database Type
16
+
17
+ - mysql
18
+ - mariadb
19
+
20
+ ## 📄 Licenc
21
+
22
+ MIT
23
+
24
+ ## 🌐 Website
25
+
26
+ The official website of the package: [https://flutry.com/docs/package/sequelize](https://flutry.com/docs/package/sequelize)
@@ -2,6 +2,9 @@ import { Sequelize } from 'sequelize';
2
2
  export declare class Flutry_Connect {
3
3
  static sequelize: Sequelize;
4
4
  private readonly functions;
5
+ private retryCount;
6
+ private maxRetries;
7
+ private retryDelay;
5
8
  constructor();
6
9
  private init;
7
10
  private connect;
@@ -8,6 +8,9 @@ const models_1 = require("../models/models");
8
8
  class Flutry_Connect {
9
9
  constructor() {
10
10
  this.functions = new function_1.Functions();
11
+ this.retryCount = 0;
12
+ this.maxRetries = 5; // Maximum retry attempts
13
+ this.retryDelay = 5000; // 5 seconds
11
14
  this.init = async () => {
12
15
  if (await this.functions.DBConfigVerify()) {
13
16
  this.connect();
@@ -24,9 +27,21 @@ class Flutry_Connect {
24
27
  await Flutry_Connect.sequelize.authenticate();
25
28
  //Flutry_Sequelize.logger.info('Connection has been established successfully'); //! This line commented for now
26
29
  await new models_1.Flutry_Models();
30
+ this.retryCount = 0; // Reset retry count on successful connection
27
31
  }
28
32
  catch (error) {
29
- main_1.Flutry_Sequelize.logger.error('Unebale to connect to the database');
33
+ main_1.Flutry_Sequelize.logger.error(`Unable to connect to the database. Attempt ${this.retryCount + 1}/${this.maxRetries}`);
34
+ if (this.retryCount < this.maxRetries) {
35
+ this.retryCount++;
36
+ main_1.Flutry_Sequelize.logger.info(`Retrying connection in ${this.retryDelay / 1000} seconds...`);
37
+ setTimeout(() => {
38
+ this.connect();
39
+ }, this.retryDelay);
40
+ }
41
+ else {
42
+ main_1.Flutry_Sequelize.logger.error('Maximum retry attempts reached. Unable to connect to database.');
43
+ this.retryCount = 0; // Reset for potential future attempts
44
+ }
30
45
  }
31
46
  };
32
47
  this.init();
@@ -17,7 +17,7 @@ class FlutryDatabase {
17
17
  static async update(model, values, options) {
18
18
  const result = await model.update(values, { ...options, returning: true });
19
19
  if (Array.isArray(result)) {
20
- const [count, updatedRows] = result;
20
+ const [_count, updatedRows] = result;
21
21
  if (Array.isArray(updatedRows)) {
22
22
  return updatedRows.map((row) => row.get({ plain: true }));
23
23
  }
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
- {
2
- "name": "@flutry/sequelize",
3
- "version": "0.0.5",
4
- "main": "dist/index.js",
5
- "types": "dist/index.d.ts",
6
- "files": [
7
- "dist"
8
- ],
9
- "scripts": {
10
- "build": "tsc"
11
- },
12
- "license": "MIT",
13
- "dependencies": {
14
- "dotenv": "^17.0.0",
15
- "mariadb": "^3.4.2",
16
- "mysql2": "^3.14.1",
17
- "sequelize": "^6.37.7"
18
- },
19
- "devDependencies": {
20
- "typescript": "^5.8.3"
21
- }
22
- }
1
+ {
2
+ "name": "@flutry/sequelize",
3
+ "version": "0.0.7",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "scripts": {
10
+ "build": "tsc"
11
+ },
12
+ "license": "MIT",
13
+ "dependencies": {
14
+ "dotenv": "^17.2.3",
15
+ "mariadb": "^3.4.5",
16
+ "mysql2": "^3.15.2",
17
+ "sequelize": "^6.37.7"
18
+ },
19
+ "devDependencies": {
20
+ "typescript": "^5.9.3"
21
+ }
22
+ }