cgserver 12.0.3 → 12.0.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.
- package/README.md +3 -0
- package/dist/lib/Framework/Database/Mongo/MongoBaseService.js +4 -4
- package/dist/lib/Framework/Database/Mongo/MongoManager.js +6 -6
- package/dist/lib/Framework/Server/RpcWebSocketServer/IRpcClientWebSocket.js +1 -1
- package/dist/lib/Framework/Server/WebServer/Controller/MongoBaseUserController.js +1 -1
- package/dist/lib/Framework/Server/WebServer/Controller/MysqlBaseUserController.js +1 -1
- package/dist/lib/Framework/Server/WebSocketServer/IWebSocketServer.js +1 -1
- package/dist/lib/Framework/Service/MongoCacheService.js +1 -1
- package/dist/types/Framework/Database/Mongo/MongoBaseService.d.ts +2 -2
- package/dist/types/Framework/Database/Mongo/MongoManager.d.ts +2 -2
- package/dist/types/Framework/Server/SocketServer/IClientSocket.d.ts +0 -1
- package/dist/types/Framework/Server/SocketServer/IServerSocket.d.ts +0 -1
- package/dist/types/Framework/Server/SocketServer/ISocket.d.ts +0 -1
- package/dist/types/Framework/Server/SocketServer/PacketParser.d.ts +2 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -66,12 +66,12 @@ class MongoBaseService {
|
|
|
66
66
|
let rs = await this.mongoDb.simpleAggregate(this._table, where, property, null, num);
|
|
67
67
|
return rs.list;
|
|
68
68
|
}
|
|
69
|
-
async updateOne(where, model,
|
|
70
|
-
let rs = await this.mongoDb.updateOne(this._table, where, model,
|
|
69
|
+
async updateOne(where, model, options) {
|
|
70
|
+
let rs = await this.mongoDb.updateOne(this._table, where, model, options);
|
|
71
71
|
return rs;
|
|
72
72
|
}
|
|
73
|
-
async updateMany(where, model = null,
|
|
74
|
-
let rs = await this.mongoDb.updateMany(this._table, where, model,
|
|
73
|
+
async updateMany(where, model = null, options) {
|
|
74
|
+
let rs = await this.mongoDb.updateMany(this._table, where, model, options);
|
|
75
75
|
return rs;
|
|
76
76
|
}
|
|
77
77
|
async insert(model) {
|
|
@@ -374,7 +374,7 @@ class MongoExt {
|
|
|
374
374
|
rs.rs = in_rs;
|
|
375
375
|
return rs;
|
|
376
376
|
}
|
|
377
|
-
async updateOne(collection, where, model,
|
|
377
|
+
async updateOne(collection, where, model, options) {
|
|
378
378
|
let _id = model["_id"];
|
|
379
379
|
delete model["_id"];
|
|
380
380
|
if (!where && _id) {
|
|
@@ -405,10 +405,10 @@ class MongoExt {
|
|
|
405
405
|
updatemodel = model;
|
|
406
406
|
}
|
|
407
407
|
let col = this._mongoDb.collection(collection);
|
|
408
|
-
up_rs = await col.updateOne(where, updatemodel,
|
|
408
|
+
up_rs = await col.updateOne(where, updatemodel, options);
|
|
409
409
|
}
|
|
410
410
|
catch (e) {
|
|
411
|
-
Log_1.gLog.error({ collection, model, where,
|
|
411
|
+
Log_1.gLog.error({ collection, model, where, options });
|
|
412
412
|
Log_1.gLog.error(e.stack);
|
|
413
413
|
rs.errcode = _error_1.EErrorCode.Mongo_Error;
|
|
414
414
|
}
|
|
@@ -418,7 +418,7 @@ class MongoExt {
|
|
|
418
418
|
}
|
|
419
419
|
return rs;
|
|
420
420
|
}
|
|
421
|
-
async updateMany(collection, where, model,
|
|
421
|
+
async updateMany(collection, where, model, options) {
|
|
422
422
|
this._convertWhere(where);
|
|
423
423
|
let rs = { errcode: null, rs: null };
|
|
424
424
|
if (!this._mongoDb) {
|
|
@@ -436,10 +436,10 @@ class MongoExt {
|
|
|
436
436
|
updateModel = model;
|
|
437
437
|
}
|
|
438
438
|
let col = this._mongoDb.collection(collection);
|
|
439
|
-
up_rs = await col.updateMany(where, updateModel,
|
|
439
|
+
up_rs = await col.updateMany(where, updateModel, options);
|
|
440
440
|
}
|
|
441
441
|
catch (e) {
|
|
442
|
-
Log_1.gLog.error({ collection, model, where,
|
|
442
|
+
Log_1.gLog.error({ collection, model, where, options });
|
|
443
443
|
Log_1.gLog.error(e.stack);
|
|
444
444
|
rs.errcode = _error_1.EErrorCode.Mongo_Error;
|
|
445
445
|
}
|
|
@@ -156,7 +156,7 @@ class IRpcClientWebSocket extends IClientWebSocket_1.IClientWebSocket {
|
|
|
156
156
|
super(server);
|
|
157
157
|
this._debug_msg = true;
|
|
158
158
|
this._group = "";
|
|
159
|
-
this._id =
|
|
159
|
+
this._id = Core_1.core.getUuid();
|
|
160
160
|
}
|
|
161
161
|
getWsByGroup(group, listen) {
|
|
162
162
|
let wses = [];
|
|
@@ -140,7 +140,7 @@ class MongoBaseUserController extends BaseController_1.BaseController {
|
|
|
140
140
|
cm.key = this._session_id;
|
|
141
141
|
cm.data = user.id;
|
|
142
142
|
cm.expireAt = Date.now() + time * 1000;
|
|
143
|
-
MongoCacheService_1.gMongoCacheSer.updateOne({ key: cm.key }, cm, true);
|
|
143
|
+
MongoCacheService_1.gMongoCacheSer.updateOne({ key: cm.key }, cm, { upsert: true });
|
|
144
144
|
}
|
|
145
145
|
this._self_user = user;
|
|
146
146
|
}
|
|
@@ -138,7 +138,7 @@ class MysqlBaseUserController extends BaseController_1.BaseController {
|
|
|
138
138
|
cm.key = this._session_id;
|
|
139
139
|
cm.data = user.id;
|
|
140
140
|
cm.expireAt = Date.now() + time * 1000;
|
|
141
|
-
MongoCacheService_1.gMongoCacheSer.updateOne({ key: cm.key }, cm, true);
|
|
141
|
+
MongoCacheService_1.gMongoCacheSer.updateOne({ key: cm.key }, cm, { upsert: true });
|
|
142
142
|
}
|
|
143
143
|
this._self_user = user;
|
|
144
144
|
}
|
|
@@ -164,7 +164,7 @@ class IWebSocketServer {
|
|
|
164
164
|
this.createWebSocketObjectByProtocol(server_name, conn, req);
|
|
165
165
|
}
|
|
166
166
|
catch (e) {
|
|
167
|
-
Log_1.gLog.error(
|
|
167
|
+
Log_1.gLog.error(e);
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
createWebSocketObjectByProtocol(server_name, _ws, req) {
|
|
@@ -39,7 +39,7 @@ class MongoCacheService extends MongoBaseService_1.MongoBaseService {
|
|
|
39
39
|
mcm.key = key;
|
|
40
40
|
mcm.data = data;
|
|
41
41
|
mcm.expireAt = expireAt;
|
|
42
|
-
let rs = await this.updateOne({ key: mcm.key }, mcm, true);
|
|
42
|
+
let rs = await this.updateOne({ key: mcm.key }, mcm, { upsert: true });
|
|
43
43
|
if (rs.rs.upsertedCount <= 0) {
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
@@ -40,7 +40,7 @@ export declare class MongoBaseService<T extends MongoBaseModel> {
|
|
|
40
40
|
}): Promise<T[]>;
|
|
41
41
|
updateOne(where: {
|
|
42
42
|
[key: string]: any;
|
|
43
|
-
}, model: any,
|
|
43
|
+
}, model: any, options?: mongo.UpdateOptions): Promise<{
|
|
44
44
|
errcode: {
|
|
45
45
|
id: number;
|
|
46
46
|
des: string;
|
|
@@ -49,7 +49,7 @@ export declare class MongoBaseService<T extends MongoBaseModel> {
|
|
|
49
49
|
}>;
|
|
50
50
|
updateMany(where: {
|
|
51
51
|
[key: string]: any;
|
|
52
|
-
}, model?: any,
|
|
52
|
+
}, model?: any, options?: mongo.UpdateOptions): Promise<{
|
|
53
53
|
errcode: {
|
|
54
54
|
id: number;
|
|
55
55
|
des: string;
|
|
@@ -158,7 +158,7 @@ export declare class MongoExt {
|
|
|
158
158
|
}>;
|
|
159
159
|
updateOne(collection: string, where: {
|
|
160
160
|
[key: string]: any;
|
|
161
|
-
}, model: any,
|
|
161
|
+
}, model: any, options?: mongo.UpdateOptions): Promise<{
|
|
162
162
|
errcode: {
|
|
163
163
|
id: number;
|
|
164
164
|
des: string;
|
|
@@ -167,7 +167,7 @@ export declare class MongoExt {
|
|
|
167
167
|
}>;
|
|
168
168
|
updateMany(collection: string, where: {
|
|
169
169
|
[key: string]: any;
|
|
170
|
-
}, model: any,
|
|
170
|
+
}, model: any, options?: mongo.UpdateOptions): Promise<{
|
|
171
171
|
errcode: {
|
|
172
172
|
id: number;
|
|
173
173
|
des: string;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
2
|
export declare class PacketParser {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
protected buffer: Buffer;
|
|
4
|
+
protected offset: number;
|
|
6
5
|
constructor();
|
|
7
6
|
push(chunk: Buffer): void;
|
|
8
7
|
parse(): Buffer | null;
|