cgserver 13.1.4 → 13.1.5
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.
|
@@ -116,13 +116,13 @@ class MongoExt {
|
|
|
116
116
|
this._mongocfg = cfg;
|
|
117
117
|
this._inited = true;
|
|
118
118
|
Log_1.gLog.info("mongo config=" + JSON.stringify(this._mongocfg));
|
|
119
|
-
mongoose_1.default.connection.on("connected", this.onConnect.bind(this));
|
|
120
|
-
mongoose_1.default.connection.on("disconnected", this.onDisconnect.bind(this));
|
|
121
119
|
mongoose_1.default.connection.on("open", this.onOpen.bind(this));
|
|
122
120
|
mongoose_1.default.connection.on("close", this.onClose.bind(this));
|
|
123
121
|
this._mongocfg.options.dbName = this._mongocfg.database;
|
|
124
|
-
await mongoose_1.default.connect("mongodb://" + this._mongocfg.host + ":" + this._mongocfg.port, this._mongocfg.options);
|
|
122
|
+
let mg = await mongoose_1.default.connect("mongodb://" + this._mongocfg.host + ":" + this._mongocfg.port, this._mongocfg.options);
|
|
125
123
|
mongoose_1.default.connection.useDb(this._mongocfg.database);
|
|
124
|
+
mongoose_1.default.connection.getClient().on("connectionCreated", this.onConnect.bind(this));
|
|
125
|
+
mongoose_1.default.connection.getClient().on("connectionClosed", this.onDisconnect.bind(this));
|
|
126
126
|
console.log("mongo connect success! db=" + this._mongocfg.database);
|
|
127
127
|
return true;
|
|
128
128
|
}
|