cgserver 13.2.18 → 13.2.20

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.
@@ -444,7 +444,7 @@ class core {
444
444
  totalProbability = eval(probabilitys.join("+"));
445
445
  }
446
446
  if (totalProbability > 1) {
447
- random = _.random(totalProbability);
447
+ random = _.random(totalProbability - 1);
448
448
  }
449
449
  else {
450
450
  random = Math.random();
@@ -34,7 +34,7 @@ class MongoCacheService extends MongoBaseService_1.MongoBaseService {
34
34
  if (expireAt) {
35
35
  m.expireAt = expireAt;
36
36
  }
37
- let model = await this.insert(m);
37
+ let model = await this.updateOne({ key: key }, m, { upsert: true });
38
38
  return model;
39
39
  }
40
40
  }
@@ -1,3 +1,4 @@
1
+ import mongoose from "mongoose";
1
2
  import { MongoBaseService } from "../Database/Mongo/MongoBaseService";
2
3
  import { IMongoBaseModel } from "../Database/Mongo/MongoManager";
3
4
  export interface IMongoCacheModel extends IMongoBaseModel {
@@ -12,6 +13,6 @@ export interface IMongoCacheModel extends IMongoBaseModel {
12
13
  export declare class MongoCacheService extends MongoBaseService<IMongoCacheModel> {
13
14
  constructor();
14
15
  getData(key: string): Promise<any>;
15
- addData(key: string, data: any, expireAt?: Date): Promise<IMongoCacheModel>;
16
+ addData(key: string, data: any, expireAt?: Date): Promise<mongoose.UpdateWriteOpResult>;
16
17
  }
17
18
  export declare let gMongoCacheSer: MongoCacheService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cgserver",
3
- "version": "13.2.18",
3
+ "version": "13.2.20",
4
4
  "author": "trojan",
5
5
  "type": "commonjs",
6
6
  "description": "free for all.Websocket or Http",