cgserver 8.6.0 → 8.6.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,3 +1,4 @@
|
|
|
1
|
-
8.
|
|
2
|
-
1
|
|
3
|
-
|
|
1
|
+
8.6.12
|
|
2
|
+
1、C# post url-encoded data support
|
|
3
|
+
8.6.1
|
|
4
|
+
1、quickTrasaction support options
|
|
@@ -440,12 +440,12 @@ class MongoManager {
|
|
|
440
440
|
* @param collection
|
|
441
441
|
* @param cb
|
|
442
442
|
*/
|
|
443
|
-
async quickTransaction(cb) {
|
|
443
|
+
async quickTransaction(cb, options) {
|
|
444
444
|
if (!this._mongoDb) {
|
|
445
445
|
return false;
|
|
446
446
|
}
|
|
447
447
|
let session = this._mongoClient.startSession();
|
|
448
|
-
session.startTransaction();
|
|
448
|
+
session.startTransaction(options);
|
|
449
449
|
try {
|
|
450
450
|
let rs = await cb(session);
|
|
451
451
|
await session.commitTransaction();
|
|
@@ -454,9 +454,11 @@ class MongoManager {
|
|
|
454
454
|
}
|
|
455
455
|
catch (e) {
|
|
456
456
|
await session.abortTransaction();
|
|
457
|
-
session.endSession();
|
|
458
457
|
Log_1.GLog.error(e.stack);
|
|
459
458
|
}
|
|
459
|
+
finally {
|
|
460
|
+
await session.endSession();
|
|
461
|
+
}
|
|
460
462
|
return false;
|
|
461
463
|
}
|
|
462
464
|
}
|
|
@@ -53,19 +53,32 @@ class Request {
|
|
|
53
53
|
}
|
|
54
54
|
get postData() {
|
|
55
55
|
var body = this._req.body || {};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
//特殊处理C#的post x-www-form-urlencoded 数据,这个数据很奇怪会把整体数据作为一个key,然后value为空字符串
|
|
57
|
+
let keys = Object.keys(body);
|
|
58
|
+
if (keys.length == 1
|
|
59
|
+
&& body[keys[0]] == ""
|
|
60
|
+
&& Core_1.core.isObject(keys[0])) {
|
|
61
|
+
body = keys[0];
|
|
62
|
+
}
|
|
63
|
+
// 暂时去掉强制数值转换
|
|
64
|
+
// //服务器会有一层空key的json解析
|
|
65
|
+
// for(let k in body)
|
|
66
|
+
// {
|
|
67
|
+
// var v = body[k]
|
|
68
|
+
// if(!core.isString(v))
|
|
69
|
+
// {
|
|
70
|
+
// continue
|
|
71
|
+
// }
|
|
72
|
+
// let intv = parseInt(v)
|
|
73
|
+
// if(intv==v)
|
|
74
|
+
// {
|
|
75
|
+
// body[k]=intv
|
|
76
|
+
// }
|
|
77
|
+
// else if(parseFloat(v)==v)
|
|
78
|
+
// {
|
|
79
|
+
// body[k]==parseFloat(v)
|
|
80
|
+
// }
|
|
81
|
+
// }
|
|
69
82
|
return body;
|
|
70
83
|
}
|
|
71
84
|
get url() {
|
|
@@ -11,16 +11,16 @@ export declare class MongoBaseService<T> {
|
|
|
11
11
|
constructor(table: string, type: {
|
|
12
12
|
new (): T;
|
|
13
13
|
});
|
|
14
|
-
getNextId(key?: string): Promise<
|
|
14
|
+
getNextId(key?: string): Promise<number>;
|
|
15
15
|
/**
|
|
16
16
|
* 没有id(非_id)的表不能使用该函数
|
|
17
17
|
* @param id
|
|
18
18
|
*/
|
|
19
|
-
getById(id: any): Promise<
|
|
20
|
-
get(proterty?: {}, where?: {}): Promise<
|
|
19
|
+
getById(id: any): Promise<T>;
|
|
20
|
+
get(proterty?: {}, where?: {}): Promise<T>;
|
|
21
21
|
countDocuments(where?: {}, options?: mongo.CountDocumentsOptions): Promise<number>;
|
|
22
|
-
gets(property?: {}, where?: {}, sort?: {}, skip?: number, limit?: number): Promise<
|
|
23
|
-
getRandoms(num: number, proterty?: {}, where?: {}): Promise<
|
|
22
|
+
gets(property?: {}, where?: {}, sort?: {}, skip?: number, limit?: number): Promise<T[]>;
|
|
23
|
+
getRandoms(num: number, proterty?: {}, where?: {}): Promise<T[]>;
|
|
24
24
|
updateOne(model: any, where?: {}, upsert?: boolean): Promise<{
|
|
25
25
|
errcode: {
|
|
26
26
|
id: number;
|
|
@@ -57,7 +57,7 @@ declare class MongoManager {
|
|
|
57
57
|
* @param key
|
|
58
58
|
* @returns 小于等于0为异常
|
|
59
59
|
*/
|
|
60
|
-
getAutoIds(key: string): Promise<
|
|
60
|
+
getAutoIds(key: string): Promise<number>;
|
|
61
61
|
protected _convertWhere(where?: any): any;
|
|
62
62
|
/**
|
|
63
63
|
* 获取单条消息
|
|
@@ -151,6 +151,6 @@ declare class MongoManager {
|
|
|
151
151
|
* @param collection
|
|
152
152
|
* @param cb
|
|
153
153
|
*/
|
|
154
|
-
quickTransaction(cb: Function): Promise<false | any>;
|
|
154
|
+
quickTransaction(cb: Function, options?: mongo.TransactionOptions): Promise<false | any>;
|
|
155
155
|
}
|
|
156
156
|
export {};
|