cgserver 13.2.0 → 13.2.2

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,4 +1,10 @@
1
1
  # 版本更新日志
2
+ ## v13.2.2
3
+ - Fix MongoDB connection initialization logic
4
+ ## v13.2.1
5
+ - Fix MongoManager to use correct connection for stats
6
+ ## v13.2.0
7
+ - Refactor MongoDB service to support multiple databases
2
8
  ## v13+
3
9
  - 主要是mongo更换为mongoose,老项目不要升级
4
10
 
@@ -135,13 +135,14 @@ class MongoExt {
135
135
  this._inited = true;
136
136
  Log_1.gLog.info("mongo config=" + JSON.stringify(this._mongocfg));
137
137
  this._mongocfg.options.dbName = this._mongocfg.database;
138
- this._connection = await mongoose_2.default.createConnection("mongodb://" + this._mongocfg.host + ":" + this._mongocfg.port, this._mongocfg.options);
138
+ this._connection = mongoose_2.default.createConnection("mongodb://" + this._mongocfg.host + ":" + this._mongocfg.port, this._mongocfg.options);
139
+ this._connection = this._connection.useDb(this._mongocfg.database);
139
140
  this._connection.on("open", this.onOpen.bind(this));
140
141
  this._connection.on("close", this.onClose.bind(this));
141
- this._connection.useDb(this._mongocfg.database);
142
142
  this._connection.on("connectionCreated", this.onConnect.bind(this));
143
143
  this._connection.on("connectionClosed", this.onDisconnect.bind(this));
144
- console.log("mongo connect success! db=" + this._connection.db.databaseName);
144
+ await this._connection.asPromise();
145
+ console.log("mongo connect success! db=" + this._connection.name);
145
146
  return true;
146
147
  }
147
148
  onConnect() {
@@ -171,7 +172,7 @@ class MongoExt {
171
172
  //this.init(this._mongocfg)
172
173
  }
173
174
  async getConnectionStats() {
174
- const stats = await mongoose_2.default.connection.db.admin().serverStatus();
175
+ const stats = await this._connection.db.admin().serverStatus();
175
176
  let current = stats.connections.current;
176
177
  let available = stats.connections.available;
177
178
  return { current, available };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cgserver",
3
- "version": "13.2.0",
3
+ "version": "13.2.2",
4
4
  "author": "trojan",
5
5
  "type": "commonjs",
6
6
  "description": "free for all.Websocket or Http",