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
|
@@ -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 =
|
|
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
|
-
|
|
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
|
|
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 };
|