agrs-sequelize-sdk 1.1.4 → 1.1.6

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.
Files changed (2) hide show
  1. package/index.js +95 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -72,3 +72,98 @@ class DBModels {
72
72
  }
73
73
 
74
74
  module.exports = DBModels;
75
+
76
+ // const Sequelize = require("sequelize");
77
+ // const path = require("path");
78
+ // const fs = require("fs");
79
+
80
+ // class DBModels {
81
+ // constructor(config) {
82
+ // this.config = config;
83
+ // this.db = {};
84
+
85
+ // const sequelize = new Sequelize(
86
+ // this.config.database,
87
+ // this.config.username,
88
+ // this.config.password,
89
+ // {
90
+ // host: this.config.host,
91
+ // dialect: this.config.dialect,
92
+ // port: this.config.port,
93
+ // logging: false,
94
+ // dialectOptions: {
95
+ // ssl: {
96
+ // require: true,
97
+ // rejectUnauthorized: false,
98
+ // },
99
+ // statement_timeout: 30000,
100
+ // idle_in_transaction_session_timeout: 30000,
101
+ // connectTimeout: 30000,
102
+ // },
103
+ // pool: {
104
+ // max: 50, // Quarter of max connections (200)
105
+ // min: 0, // Start from 0 and scale up as needed
106
+ // acquire: 30000, // Maximum time to wait for a connection
107
+ // idle: 10000, // How long a connection can remain idle
108
+ // },
109
+ // retry: {
110
+ // max: 3,
111
+ // timeout: 20000,
112
+ // match: [
113
+ // /Connection terminated/,
114
+ // /Connection timed out/,
115
+ // /Operation timeout/,
116
+ // /ECONNRESET/,
117
+ // /PROTOCOL_CONNECTION_LOST/,
118
+ // ],
119
+ // },
120
+ // }
121
+ // );
122
+
123
+ // // Add connection monitoring listeners
124
+ // sequelize.connectionManager.on("acquire", function (connection) {
125
+ // console.log("Connection %d acquired", connection.threadId);
126
+ // });
127
+
128
+ // sequelize.connectionManager.on("release", function (connection) {
129
+ // console.log("Connection %d released", connection.threadId);
130
+ // });
131
+
132
+ // // Load all models
133
+ // fs.readdirSync(path.join(__dirname, "models"))
134
+ // .filter((file) => {
135
+ // return file.indexOf(".") !== 0 && file.slice(-3) === ".js";
136
+ // })
137
+ // .forEach((file) => {
138
+ // const model = require(path.join(__dirname, "models", file))(
139
+ // sequelize,
140
+ // Sequelize.DataTypes
141
+ // );
142
+ // this.db[model.name] = model;
143
+ // });
144
+
145
+ // // Set up associations
146
+ // Object.keys(this.db).forEach((modelName) => {
147
+ // if (this.db[modelName].associate) {
148
+ // this.db[modelName].associate(this.db);
149
+ // }
150
+ // });
151
+
152
+ // // Export the db object with Sequelize and models
153
+ // this.db.sequelize = sequelize;
154
+ // this.db.Sequelize = Sequelize;
155
+ // }
156
+
157
+ // // Add method for pool monitoring
158
+ // async getConnectionPoolStats() {
159
+ // const pool = this.db.sequelize.connectionManager.pool;
160
+ // return {
161
+ // all: pool.size,
162
+ // available: pool.available,
163
+ // borrowed: pool.borrowed,
164
+ // pending: pool.pending,
165
+ // };
166
+ // }
167
+ // }
168
+
169
+ // module.exports = DBModels;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agrs-sequelize-sdk",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "start": "node index.js",