cgserver 10.0.9 → 10.0.10
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.
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MongoBaseService = void 0;
|
|
4
4
|
const MongoManager_1 = require("./MongoManager");
|
|
5
|
+
const MongoServiceManager_1 = require("./MongoServiceManager");
|
|
5
6
|
class MongoBaseService {
|
|
6
7
|
_table = "";
|
|
7
8
|
get table() {
|
|
@@ -29,6 +30,7 @@ class MongoBaseService {
|
|
|
29
30
|
this._t_type = type;
|
|
30
31
|
this._table = table;
|
|
31
32
|
this._dbname = dbname;
|
|
33
|
+
MongoServiceManager_1.gMongoServiceMgr.addService(this);
|
|
32
34
|
}
|
|
33
35
|
async getNextId(key = "") {
|
|
34
36
|
if (!key) {
|
|
@@ -1,40 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.gMongoServiceMgr = exports.MongoServiceManager = void 0;
|
|
4
|
+
const index_export_1 = require("../../index_export_");
|
|
5
|
+
const MongoManager_1 = require("./MongoManager");
|
|
4
6
|
class MongoServiceManager {
|
|
5
7
|
_services = {};
|
|
6
|
-
addService(service
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
8
|
+
addService(service) {
|
|
9
|
+
let dbname = service.dbname;
|
|
10
|
+
dbname = this._tryDef(dbname);
|
|
10
11
|
let table = service.table;
|
|
11
12
|
if (!this._services[dbname][table]) {
|
|
12
|
-
if (service.dbname != dbname) {
|
|
13
|
-
service = Object.assign({}, service);
|
|
14
|
-
service.dbname = dbname;
|
|
15
|
-
}
|
|
16
13
|
this._services[dbname][table] = service;
|
|
17
14
|
}
|
|
18
15
|
return this._services[dbname][table];
|
|
19
16
|
}
|
|
20
|
-
|
|
21
|
-
if (!
|
|
22
|
-
|
|
17
|
+
_tryDef(dbname) {
|
|
18
|
+
if (!dbname) {
|
|
19
|
+
dbname = MongoManager_1.gMongoMgr.defdbname;
|
|
20
|
+
if (dbname && !this._services[dbname]) {
|
|
21
|
+
this._services[dbname] = this._services[""];
|
|
22
|
+
delete this._services[""];
|
|
23
|
+
}
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
else {
|
|
26
|
+
if (dbname == MongoManager_1.gMongoMgr.defdbname && !this._services[dbname]) {
|
|
27
|
+
this._services[dbname] = this._services[""];
|
|
28
|
+
delete this._services[""];
|
|
29
|
+
}
|
|
26
30
|
}
|
|
27
|
-
return this._services[dbname][table];
|
|
28
|
-
}
|
|
29
|
-
getService(service, dbname = "") {
|
|
30
31
|
if (!this._services[dbname]) {
|
|
31
32
|
this._services[dbname] = {};
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
return dbname;
|
|
35
|
+
}
|
|
36
|
+
getService(table, dbname = "") {
|
|
37
|
+
dbname = this._tryDef(dbname);
|
|
38
|
+
let tablename = "";
|
|
39
|
+
if (index_export_1.core.isString(table)) {
|
|
40
|
+
tablename = table;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
tablename = table.table;
|
|
44
|
+
}
|
|
45
|
+
if (!this._services[dbname][tablename]) {
|
|
35
46
|
return null;
|
|
36
47
|
}
|
|
37
|
-
return this._services[dbname][
|
|
48
|
+
return this._services[dbname][tablename];
|
|
38
49
|
}
|
|
39
50
|
}
|
|
40
51
|
exports.MongoServiceManager = MongoServiceManager;
|
|
@@ -6,8 +6,8 @@ export declare class MongoServiceManager {
|
|
|
6
6
|
[table: string]: MongoBaseService<MongoBaseModel>;
|
|
7
7
|
};
|
|
8
8
|
};
|
|
9
|
-
addService<T extends MongoBaseService<MongoBaseModel>>(service: T
|
|
10
|
-
|
|
11
|
-
getService<T extends MongoBaseService<MongoBaseModel>>(
|
|
9
|
+
addService<T extends MongoBaseService<MongoBaseModel>>(service: T): T;
|
|
10
|
+
protected _tryDef(dbname: string): string;
|
|
11
|
+
getService<T extends MongoBaseService<MongoBaseModel>>(table: T | string, dbname?: string): T;
|
|
12
12
|
}
|
|
13
13
|
export declare let gMongoServiceMgr: MongoServiceManager;
|