@builder6/tables 0.6.1
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 +18 -0
- package/dist/app.module.d.ts +2 -0
- package/dist/app.module.js +22 -0
- package/dist/app.module.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/tables/index.d.ts +4 -0
- package/dist/tables/index.js +21 -0
- package/dist/tables/index.js.map +1 -0
- package/dist/tables/meta.service.d.ts +6 -0
- package/dist/tables/meta.service.js +100 -0
- package/dist/tables/meta.service.js.map +1 -0
- package/dist/tables/tables.controller.d.ts +23 -0
- package/dist/tables/tables.controller.js +343 -0
- package/dist/tables/tables.controller.js.map +1 -0
- package/dist/tables/tables.module.d.ts +2 -0
- package/dist/tables/tables.module.js +26 -0
- package/dist/tables/tables.module.js.map +1 -0
- package/dist/tables/tables.service.d.ts +30 -0
- package/dist/tables/tables.service.js +148 -0
- package/dist/tables/tables.service.js.map +1 -0
- package/package.json +22 -0
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Builder6 Email Module
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## Environment Variables
|
|
5
|
+
|
|
6
|
+
```shell
|
|
7
|
+
B6_EMAIL_FROM=Steedos <noreply@steedos.com>
|
|
8
|
+
B6_EMAIL_HOST=email.xxxx.amazonaws.com
|
|
9
|
+
B6_EMAIL_PORT=465
|
|
10
|
+
B6_EMAIL_USERNAME=xxxxx
|
|
11
|
+
B6_EMAIL_PASSWORD=xxxxx
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## 配置定时发送
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
STEEDOS_CRON_MAILQUEUE_INTERVAL=3000 # 邮件定时器,单位:毫秒
|
|
18
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AppModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const tables_module_1 = require("./tables/tables.module");
|
|
12
|
+
let AppModule = class AppModule {
|
|
13
|
+
};
|
|
14
|
+
exports.AppModule = AppModule;
|
|
15
|
+
exports.AppModule = AppModule = __decorate([
|
|
16
|
+
(0, common_1.Module)({
|
|
17
|
+
imports: [tables_module_1.TablesModule],
|
|
18
|
+
controllers: [],
|
|
19
|
+
providers: [],
|
|
20
|
+
})
|
|
21
|
+
], AppModule);
|
|
22
|
+
//# sourceMappingURL=app.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,0DAAsD;AAO/C,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IALrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,4BAAY,CAAC;QACvB,WAAW,EAAE,EAAE;QACf,SAAS,EAAE,EAAE;KACd,CAAC;GACW,SAAS,CAAG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tables';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./tables"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./meta.service"), exports);
|
|
18
|
+
__exportStar(require("./tables.controller"), exports);
|
|
19
|
+
__exportStar(require("./tables.service"), exports);
|
|
20
|
+
__exportStar(require("./tables.module"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tables/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,sDAAoC;AACpC,mDAAiC;AACjC,kDAAgC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MongodbService } from '@builder6/core';
|
|
2
|
+
export declare class MetaService {
|
|
3
|
+
private readonly mongodbService;
|
|
4
|
+
constructor(mongodbService: MongodbService);
|
|
5
|
+
getTableMeta(baseId: string, tableId: string): Promise<import("mongodb").WithId<import("bson").Document>>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MetaService = void 0;
|
|
13
|
+
const core_1 = require("@builder6/core");
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
let MetaService = class MetaService {
|
|
16
|
+
constructor(mongodbService) {
|
|
17
|
+
this.mongodbService = mongodbService;
|
|
18
|
+
}
|
|
19
|
+
async getTableMeta(baseId, tableId) {
|
|
20
|
+
let table = await this.mongodbService.findOne('b6_tables', {
|
|
21
|
+
_id: tableId,
|
|
22
|
+
});
|
|
23
|
+
if (table) {
|
|
24
|
+
table.fields = await this.mongodbService.find('b6_fields', {
|
|
25
|
+
table_id: tableId,
|
|
26
|
+
}, { sort: { sort_no: 1 } });
|
|
27
|
+
table.verifications = await this.mongodbService.find('b6_verification', {
|
|
28
|
+
table: tableId,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
table = {
|
|
33
|
+
_id: tableId,
|
|
34
|
+
base_id: baseId,
|
|
35
|
+
name: 'Tasks',
|
|
36
|
+
description: 'I was changed!',
|
|
37
|
+
fields: [
|
|
38
|
+
{
|
|
39
|
+
_id: 'fld001',
|
|
40
|
+
name: 'name',
|
|
41
|
+
label: '名称',
|
|
42
|
+
type: 'text',
|
|
43
|
+
default_value: '默认文本',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
_id: 'fld002',
|
|
47
|
+
name: 'age',
|
|
48
|
+
label: '年龄',
|
|
49
|
+
type: 'number',
|
|
50
|
+
default_value: 20,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
_id: 'fld003',
|
|
54
|
+
name: 'discount',
|
|
55
|
+
label: '折扣',
|
|
56
|
+
type: 'number',
|
|
57
|
+
precision: 2,
|
|
58
|
+
},
|
|
59
|
+
{ _id: 'fld004', name: 'info', label: '备注', type: 'textarea' },
|
|
60
|
+
{
|
|
61
|
+
_id: 'fld005',
|
|
62
|
+
name: 'company',
|
|
63
|
+
label: '公司',
|
|
64
|
+
type: 'select',
|
|
65
|
+
options: `华炎\n建华\n中国移动`,
|
|
66
|
+
},
|
|
67
|
+
{ _id: 'fld007', name: 'birthdate', label: '生日', type: 'date' },
|
|
68
|
+
{
|
|
69
|
+
_id: 'fld008',
|
|
70
|
+
name: 'created',
|
|
71
|
+
label: '创建时间',
|
|
72
|
+
type: 'datetime',
|
|
73
|
+
default_value: '2024-12-11T09:22:09.045Z',
|
|
74
|
+
},
|
|
75
|
+
{ _id: 'fld009', name: 'valid', label: '启用', type: 'boolean' },
|
|
76
|
+
{
|
|
77
|
+
_id: 'fld010',
|
|
78
|
+
name: 'formula',
|
|
79
|
+
label: '公式',
|
|
80
|
+
type: 'formula',
|
|
81
|
+
formula: 'name + age',
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
verifications: [
|
|
85
|
+
{
|
|
86
|
+
alert: '年龄必须大于18岁',
|
|
87
|
+
rule: 'age > 18',
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return table;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
exports.MetaService = MetaService;
|
|
96
|
+
exports.MetaService = MetaService = __decorate([
|
|
97
|
+
(0, common_1.Injectable)(),
|
|
98
|
+
__metadata("design:paramtypes", [core_1.MongodbService])
|
|
99
|
+
], MetaService);
|
|
100
|
+
//# sourceMappingURL=meta.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.service.js","sourceRoot":"","sources":["../../src/tables/meta.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA,yCAAgD;AAChD,2CAA4C;AAGrC,IAAM,WAAW,GAAjB,MAAM,WAAW;IACtB,YAA6B,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;IAAG,CAAC;IAE/D,KAAK,CAAC,YAAY,CAAC,MAAc,EAAE,OAAe;QAChD,IAAI,KAAK,GAAG,MAA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AAE,cAAc;qBACxB;oBAQD,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE;oBAC/D;wBACE,GAAG,EAAE,QAAQ;wBACb,IAAI,EAAE,SAAS;wBACf,KAAK,EAAE,MAAM;wBACb,IAAI,EAAE,UAAU;wBAChB,aAAa,EAAE,0BAA0B;qBAC1C;oBACD,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;oBAC9D;wBACE,GAAG,EAAE,QAAQ;wBACb,IAAI,EAAE,SAAS;wBACf,KAAK,EAAE,IAAI;wBACX,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,YAAY;qBACtB;iBACF;gBACD,aAAa,EAAE;oBACb;wBACE,KAAK,EAAE,WAAW;wBAClB,IAAI,EAAE,UAAU;qBACjB;iBACF;aACK,CAAC;QACX,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AAxFY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;qCAEkC,qBAAc;GADhD,WAAW,CAwFvB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TablesService } from './tables.service';
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import { MetaService } from './meta.service';
|
|
4
|
+
export declare class TablesController {
|
|
5
|
+
private readonly tablesService;
|
|
6
|
+
private readonly metaService;
|
|
7
|
+
constructor(tablesService: TablesService, metaService: MetaService);
|
|
8
|
+
create(baseId: string, tableId: string, record: object, req: Request, res: Response): Promise<void>;
|
|
9
|
+
find(req: Request, res: Response, baseId: string, tableId: string, fields?: any, expands?: any, filters?: any, sort?: any, skip?: number, top?: number): Promise<void>;
|
|
10
|
+
findOne(baseId: string, tableId: string, recordId: string, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
11
|
+
update(baseId: string, tableId: string, recordId: string, body: object, req: Request, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
12
|
+
remove(baseId: string, tableId: string, recordId: string, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
13
|
+
deleteMultiple(baseId: string, tableId: string, records: [string], res: Response): Promise<Response<any, Record<string, any>>>;
|
|
14
|
+
getTableMeta(baseId: string, tableId: string, res: Response): Promise<void>;
|
|
15
|
+
getDemo(baseId: string, tableId: string): Promise<{
|
|
16
|
+
baseId: string;
|
|
17
|
+
tableId: string;
|
|
18
|
+
}>;
|
|
19
|
+
AgGrid(baseId: string, tableId: string): Promise<{
|
|
20
|
+
baseId: string;
|
|
21
|
+
tableId: string;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.TablesController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const tables_service_1 = require("./tables.service");
|
|
18
|
+
const query_mongodb_1 = require("@builder6/query-mongodb");
|
|
19
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
20
|
+
const core_1 = require("@builder6/core");
|
|
21
|
+
const meta_service_1 = require("./meta.service");
|
|
22
|
+
let TablesController = class TablesController {
|
|
23
|
+
constructor(tablesService, metaService) {
|
|
24
|
+
this.tablesService = tablesService;
|
|
25
|
+
this.metaService = metaService;
|
|
26
|
+
}
|
|
27
|
+
async create(baseId, tableId, record, req, res) {
|
|
28
|
+
const user = req['user'];
|
|
29
|
+
try {
|
|
30
|
+
const result = await this.tablesService.createRecord(baseId, tableId, {
|
|
31
|
+
...record,
|
|
32
|
+
owner: user._id,
|
|
33
|
+
created_by: user._id,
|
|
34
|
+
created: new Date(),
|
|
35
|
+
modified_by: user._id,
|
|
36
|
+
modified: new Date(),
|
|
37
|
+
space: user.space,
|
|
38
|
+
});
|
|
39
|
+
res.status(200).send(result);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
console.error('Query error', error);
|
|
43
|
+
res.status(500).send(error);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async find(req, res, baseId, tableId, fields, expands, filters, sort, skip = 0, top = 20) {
|
|
47
|
+
try {
|
|
48
|
+
const options = (0, query_mongodb_1.getOptions)(req.query, {
|
|
49
|
+
areaKM2: 'int',
|
|
50
|
+
population: 'int',
|
|
51
|
+
});
|
|
52
|
+
const loadOptions = { take: top, skip: skip, ...options.loadOptions };
|
|
53
|
+
if (filters) {
|
|
54
|
+
loadOptions.filter = JSON.parse(filters);
|
|
55
|
+
}
|
|
56
|
+
if (sort) {
|
|
57
|
+
const sortFields = sort.split(',');
|
|
58
|
+
loadOptions.sort = sortFields.map((sortField) => {
|
|
59
|
+
const [field, dir] = sortField.split(' ');
|
|
60
|
+
return { selector: field, desc: dir === 'desc' };
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (fields) {
|
|
64
|
+
try {
|
|
65
|
+
loadOptions.select = JSON.parse(fields);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
loadOptions.select = fields.split(',');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (expands) {
|
|
72
|
+
try {
|
|
73
|
+
loadOptions.expands = JSON.parse(expands);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
loadOptions.expands = expands.split(',');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const results = await this.tablesService.getRecords(baseId, tableId, loadOptions, options.processingOptions);
|
|
80
|
+
res.status(200).send(results);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.error('Query error', error);
|
|
84
|
+
res.status(500).send(error);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async findOne(baseId, tableId, recordId, res) {
|
|
88
|
+
try {
|
|
89
|
+
const result = await this.tablesService.findOne(baseId, tableId, {
|
|
90
|
+
_id: recordId,
|
|
91
|
+
});
|
|
92
|
+
if (!result) {
|
|
93
|
+
return res.status(404).send();
|
|
94
|
+
}
|
|
95
|
+
res.status(200).send(result);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
console.error('Query error', error);
|
|
99
|
+
res.status(500).send(error);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async update(baseId, tableId, recordId, body, req, res) {
|
|
103
|
+
try {
|
|
104
|
+
const record = {
|
|
105
|
+
...body,
|
|
106
|
+
modified_by: req['user']._id,
|
|
107
|
+
modified: new Date(),
|
|
108
|
+
};
|
|
109
|
+
const result = await this.tablesService.updateRecord(baseId, tableId, recordId, record);
|
|
110
|
+
if (!result) {
|
|
111
|
+
return res.status(404).send();
|
|
112
|
+
}
|
|
113
|
+
res.status(200).send(result);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
console.error('Query error', error);
|
|
117
|
+
res.status(500).send(error);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async remove(baseId, tableId, recordId, res) {
|
|
121
|
+
try {
|
|
122
|
+
const result = await this.tablesService.deleteOne(baseId, tableId, {
|
|
123
|
+
_id: recordId,
|
|
124
|
+
});
|
|
125
|
+
if (result.deletedCount === 0) {
|
|
126
|
+
return res.status(404).send();
|
|
127
|
+
}
|
|
128
|
+
res.status(200).send({ deleted: true, _id: recordId });
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
console.error('Query error', error);
|
|
132
|
+
res.status(500).send(error);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async deleteMultiple(baseId, tableId, records, res) {
|
|
136
|
+
try {
|
|
137
|
+
const result = await this.tablesService.deleteMany(baseId, tableId, {
|
|
138
|
+
_id: { $in: records },
|
|
139
|
+
});
|
|
140
|
+
if (result.deletedCount === 0) {
|
|
141
|
+
return res.status(404).send();
|
|
142
|
+
}
|
|
143
|
+
res
|
|
144
|
+
.status(200)
|
|
145
|
+
.send({ records: records.map((_id) => ({ deleted: true, _id })) });
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
console.error('Query error', error);
|
|
149
|
+
res.status(500).send(error);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
async getTableMeta(baseId, tableId, res) {
|
|
153
|
+
try {
|
|
154
|
+
const table = await this.metaService.getTableMeta(baseId, tableId);
|
|
155
|
+
res.status(200).send(table);
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
console.error('Query error', error);
|
|
159
|
+
res.status(500).send(error);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
async getDemo(baseId, tableId) {
|
|
163
|
+
return {
|
|
164
|
+
baseId,
|
|
165
|
+
tableId,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
async AgGrid(baseId, tableId) {
|
|
169
|
+
return {
|
|
170
|
+
baseId,
|
|
171
|
+
tableId,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
exports.TablesController = TablesController;
|
|
176
|
+
__decorate([
|
|
177
|
+
(0, swagger_1.ApiOperation)({ summary: 'Create a record' }),
|
|
178
|
+
(0, common_1.Post)(':baseId/:tableId'),
|
|
179
|
+
(0, swagger_1.ApiBody)({
|
|
180
|
+
schema: {
|
|
181
|
+
type: 'object',
|
|
182
|
+
},
|
|
183
|
+
}),
|
|
184
|
+
__param(0, (0, common_1.Param)('baseId')),
|
|
185
|
+
__param(1, (0, common_1.Param)('tableId')),
|
|
186
|
+
__param(2, (0, common_1.Body)()),
|
|
187
|
+
__param(3, (0, common_1.Req)()),
|
|
188
|
+
__param(4, (0, common_1.Res)()),
|
|
189
|
+
__metadata("design:type", Function),
|
|
190
|
+
__metadata("design:paramtypes", [String, String, Object, Object, Object]),
|
|
191
|
+
__metadata("design:returntype", Promise)
|
|
192
|
+
], TablesController.prototype, "create", null);
|
|
193
|
+
__decorate([
|
|
194
|
+
(0, swagger_1.ApiOperation)({ summary: 'List records' }),
|
|
195
|
+
(0, common_1.Get)(':baseId/:tableId'),
|
|
196
|
+
(0, swagger_1.ApiQuery)({
|
|
197
|
+
name: 'fields',
|
|
198
|
+
required: false,
|
|
199
|
+
description: '查询的字段,例如: "name,created"',
|
|
200
|
+
}),
|
|
201
|
+
(0, swagger_1.ApiQuery)({
|
|
202
|
+
name: 'filters',
|
|
203
|
+
required: false,
|
|
204
|
+
description: '过滤条件,示例:["age", ">", 10]',
|
|
205
|
+
}),
|
|
206
|
+
(0, swagger_1.ApiQuery)({
|
|
207
|
+
name: 'expands',
|
|
208
|
+
required: false,
|
|
209
|
+
default: 'created_by,modified_by',
|
|
210
|
+
description: '扩展相关表字段,例如: "created_by,modified_by"',
|
|
211
|
+
}),
|
|
212
|
+
(0, swagger_1.ApiQuery)({
|
|
213
|
+
name: 'sort',
|
|
214
|
+
required: false,
|
|
215
|
+
description: '排序,示例:created desc',
|
|
216
|
+
}),
|
|
217
|
+
(0, swagger_1.ApiQuery)({
|
|
218
|
+
name: 'skip',
|
|
219
|
+
required: false,
|
|
220
|
+
description: '跳过记录数',
|
|
221
|
+
default: 0,
|
|
222
|
+
}),
|
|
223
|
+
(0, swagger_1.ApiQuery)({
|
|
224
|
+
name: 'top',
|
|
225
|
+
required: false,
|
|
226
|
+
default: 20,
|
|
227
|
+
description: '每页记录数,默认20',
|
|
228
|
+
}),
|
|
229
|
+
__param(0, (0, common_1.Req)()),
|
|
230
|
+
__param(1, (0, common_1.Res)()),
|
|
231
|
+
__param(2, (0, common_1.Param)('baseId')),
|
|
232
|
+
__param(3, (0, common_1.Param)('tableId')),
|
|
233
|
+
__param(4, (0, common_1.Query)('fields')),
|
|
234
|
+
__param(5, (0, common_1.Query)('expands')),
|
|
235
|
+
__param(6, (0, common_1.Query)('filters')),
|
|
236
|
+
__param(7, (0, common_1.Query)('sort')),
|
|
237
|
+
__param(8, (0, common_1.Query)('skip', new common_1.ParseIntPipe())),
|
|
238
|
+
__param(9, (0, common_1.Query)('top', new common_1.ParseIntPipe())),
|
|
239
|
+
__metadata("design:type", Function),
|
|
240
|
+
__metadata("design:paramtypes", [Object, Object, String, String, Object, Object, Object, Object, Number, Number]),
|
|
241
|
+
__metadata("design:returntype", Promise)
|
|
242
|
+
], TablesController.prototype, "find", null);
|
|
243
|
+
__decorate([
|
|
244
|
+
(0, common_1.Get)(':baseId/:tableId/:recordId'),
|
|
245
|
+
(0, swagger_1.ApiOperation)({ summary: 'Get record' }),
|
|
246
|
+
__param(0, (0, common_1.Param)('baseId')),
|
|
247
|
+
__param(1, (0, common_1.Param)('tableId')),
|
|
248
|
+
__param(2, (0, common_1.Param)('recordId')),
|
|
249
|
+
__param(3, (0, common_1.Res)()),
|
|
250
|
+
__metadata("design:type", Function),
|
|
251
|
+
__metadata("design:paramtypes", [String, String, String, Object]),
|
|
252
|
+
__metadata("design:returntype", Promise)
|
|
253
|
+
], TablesController.prototype, "findOne", null);
|
|
254
|
+
__decorate([
|
|
255
|
+
(0, swagger_1.ApiOperation)({ summary: 'Update record' }),
|
|
256
|
+
(0, common_1.Put)(':baseId/:tableId/:recordId'),
|
|
257
|
+
(0, common_1.Patch)(':baseId/:tableId/:recordId'),
|
|
258
|
+
(0, swagger_1.ApiBody)({
|
|
259
|
+
schema: {
|
|
260
|
+
type: 'object',
|
|
261
|
+
},
|
|
262
|
+
}),
|
|
263
|
+
__param(0, (0, common_1.Param)('baseId')),
|
|
264
|
+
__param(1, (0, common_1.Param)('tableId')),
|
|
265
|
+
__param(2, (0, common_1.Param)('recordId')),
|
|
266
|
+
__param(3, (0, common_1.Body)()),
|
|
267
|
+
__param(4, (0, common_1.Req)()),
|
|
268
|
+
__param(5, (0, common_1.Res)()),
|
|
269
|
+
__metadata("design:type", Function),
|
|
270
|
+
__metadata("design:paramtypes", [String, String, String, Object, Object, Object]),
|
|
271
|
+
__metadata("design:returntype", Promise)
|
|
272
|
+
], TablesController.prototype, "update", null);
|
|
273
|
+
__decorate([
|
|
274
|
+
(0, common_1.Delete)(':baseId/:tableId/:recordId'),
|
|
275
|
+
(0, swagger_1.ApiOperation)({ summary: 'Delete record' }),
|
|
276
|
+
__param(0, (0, common_1.Param)('baseId')),
|
|
277
|
+
__param(1, (0, common_1.Param)('tableId')),
|
|
278
|
+
__param(2, (0, common_1.Param)('recordId')),
|
|
279
|
+
__param(3, (0, common_1.Res)()),
|
|
280
|
+
__metadata("design:type", Function),
|
|
281
|
+
__metadata("design:paramtypes", [String, String, String, Object]),
|
|
282
|
+
__metadata("design:returntype", Promise)
|
|
283
|
+
], TablesController.prototype, "remove", null);
|
|
284
|
+
__decorate([
|
|
285
|
+
(0, swagger_1.ApiBody)({
|
|
286
|
+
schema: {
|
|
287
|
+
type: 'object',
|
|
288
|
+
properties: {
|
|
289
|
+
records: {
|
|
290
|
+
type: 'array',
|
|
291
|
+
items: {
|
|
292
|
+
type: 'string',
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
}),
|
|
298
|
+
(0, common_1.Delete)(':baseId/:tableId'),
|
|
299
|
+
(0, swagger_1.ApiOperation)({ summary: 'Delete multiple records' }),
|
|
300
|
+
__param(0, (0, common_1.Param)('baseId')),
|
|
301
|
+
__param(1, (0, common_1.Param)('tableId')),
|
|
302
|
+
__param(2, (0, common_1.Body)('records')),
|
|
303
|
+
__param(3, (0, common_1.Res)()),
|
|
304
|
+
__metadata("design:type", Function),
|
|
305
|
+
__metadata("design:paramtypes", [String, String, Array, Object]),
|
|
306
|
+
__metadata("design:returntype", Promise)
|
|
307
|
+
], TablesController.prototype, "deleteMultiple", null);
|
|
308
|
+
__decorate([
|
|
309
|
+
(0, common_1.Get)('meta/bases/:baseId/tables/:tableId'),
|
|
310
|
+
(0, swagger_1.ApiBearerAuth)(),
|
|
311
|
+
__param(0, (0, common_1.Param)('baseId')),
|
|
312
|
+
__param(1, (0, common_1.Param)('tableId')),
|
|
313
|
+
__param(2, (0, common_1.Res)()),
|
|
314
|
+
__metadata("design:type", Function),
|
|
315
|
+
__metadata("design:paramtypes", [String, String, Object]),
|
|
316
|
+
__metadata("design:returntype", Promise)
|
|
317
|
+
], TablesController.prototype, "getTableMeta", null);
|
|
318
|
+
__decorate([
|
|
319
|
+
(0, common_1.Get)('devextreme/datagrid/:baseId/:tableId'),
|
|
320
|
+
(0, common_1.Render)('devextreme/datagrid'),
|
|
321
|
+
__param(0, (0, common_1.Param)('baseId')),
|
|
322
|
+
__param(1, (0, common_1.Param)('tableId')),
|
|
323
|
+
__metadata("design:type", Function),
|
|
324
|
+
__metadata("design:paramtypes", [String, String]),
|
|
325
|
+
__metadata("design:returntype", Promise)
|
|
326
|
+
], TablesController.prototype, "getDemo", null);
|
|
327
|
+
__decorate([
|
|
328
|
+
(0, common_1.Get)('ag-grid/ag-grid/:baseId/:tableId'),
|
|
329
|
+
(0, common_1.Render)('ag-grid/ag-grid'),
|
|
330
|
+
__param(0, (0, common_1.Param)('baseId')),
|
|
331
|
+
__param(1, (0, common_1.Param)('tableId')),
|
|
332
|
+
__metadata("design:type", Function),
|
|
333
|
+
__metadata("design:paramtypes", [String, String]),
|
|
334
|
+
__metadata("design:returntype", Promise)
|
|
335
|
+
], TablesController.prototype, "AgGrid", null);
|
|
336
|
+
exports.TablesController = TablesController = __decorate([
|
|
337
|
+
(0, common_1.Controller)('api/v6/tables/'),
|
|
338
|
+
(0, common_1.UseGuards)(core_1.AuthGuard),
|
|
339
|
+
(0, swagger_1.ApiBearerAuth)(),
|
|
340
|
+
__metadata("design:paramtypes", [tables_service_1.TablesService,
|
|
341
|
+
meta_service_1.MetaService])
|
|
342
|
+
], TablesController);
|
|
343
|
+
//# sourceMappingURL=tables.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tables.controller.js","sourceRoot":"","sources":["../../src/tables/tables.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAewB;AACxB,qDAAiD;AAEjD,2DAAqD;AACrD,6CAKyB;AACzB,yCAA2C;AAC3C,iDAA6C;AAMtC,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAC3B,YACmB,aAA4B,EAC5B,WAAwB;QADxB,kBAAa,GAAb,aAAa,CAAe;QAC5B,gBAAW,GAAX,WAAW,CAAa;IACxC,CAAC;IAeE,AAAN,KAAK,CAAC,MAAM,CACO,MAAc,EACb,OAAe,EACzB,MAAc,EACf,GAAY,EACZ,GAAa;QAEpB,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE;gBACpE,GAAG,MAAM;gBACT,KAAK,EAAE,IAAI,CAAC,GAAG;gBACf,UAAU,EAAE,IAAI,CAAC,GAAG;gBACpB,OAAO,EAAE,IAAI,IAAI,EAAE;gBACnB,WAAW,EAAE,IAAI,CAAC,GAAG;gBACrB,QAAQ,EAAE,IAAI,IAAI,EAAE;gBACpB,KAAK,EAAE,IA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qCAGoB,8BAAa;QACf,0BAAW;GAHhC,gBAAgB,CAuZ5B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TablesModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const tables_controller_1 = require("./tables.controller");
|
|
12
|
+
const tables_service_1 = require("./tables.service");
|
|
13
|
+
const meta_service_1 = require("./meta.service");
|
|
14
|
+
const core_1 = require("@builder6/core");
|
|
15
|
+
const core_2 = require("@builder6/core");
|
|
16
|
+
let TablesModule = class TablesModule {
|
|
17
|
+
};
|
|
18
|
+
exports.TablesModule = TablesModule;
|
|
19
|
+
exports.TablesModule = TablesModule = __decorate([
|
|
20
|
+
(0, common_1.Module)({
|
|
21
|
+
imports: [core_2.AuthModule, core_1.MongodbModule],
|
|
22
|
+
controllers: [tables_controller_1.TablesController],
|
|
23
|
+
providers: [meta_service_1.MetaService, tables_service_1.TablesService],
|
|
24
|
+
})
|
|
25
|
+
], TablesModule);
|
|
26
|
+
//# sourceMappingURL=tables.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tables.module.js","sourceRoot":"","sources":["../../src/tables/tables.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,2DAAuD;AACvD,qDAAiD;AACjD,iDAA6C;AAC7C,yCAA+C;AAC/C,yCAA4C;AAOrC,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,oCAAY;uBAAZ,YAAY;IALxB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,iBAAU,EAAE,oBAAa,CAAC;QACpC,WAAW,EAAE,CAAC,oCAAgB,CAAC;QAC/B,SAAS,EAAE,CAAC,0BAAW,EAAE,8BAAa,CAAC;KACxC,CAAC;GACW,YAAY,CAAG"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import 'regenerator-runtime/runtime';
|
|
2
|
+
import { Collection } from 'mongodb';
|
|
3
|
+
import { ConfigService } from '@nestjs/config';
|
|
4
|
+
import { MongodbService } from '@builder6/core';
|
|
5
|
+
export declare class TablesService {
|
|
6
|
+
private configService;
|
|
7
|
+
private readonly mongodbService;
|
|
8
|
+
private db;
|
|
9
|
+
private loaders;
|
|
10
|
+
private readonly logger;
|
|
11
|
+
constructor(configService: ConfigService, mongodbService: MongodbService);
|
|
12
|
+
getCollection(baseId: string, tableId: string): Collection;
|
|
13
|
+
createRecord(baseId: string, tableId: any, data: any): Promise<any>;
|
|
14
|
+
getRecords(baseId: string, tableId: string, loadOptions: any, processingOptions: any): Promise<any>;
|
|
15
|
+
find(baseId: string, tableId: string, query: object, options?: object): Promise<import("mongodb").WithId<import("bson").Document>[]>;
|
|
16
|
+
findOne(baseId: string, tableId: string, query: object): Promise<import("mongodb").WithId<import("bson").Document>>;
|
|
17
|
+
updateRecord(baseId: string, tableId: string, id: string, data: any): Promise<import("mongodb").WithId<import("bson").Document>>;
|
|
18
|
+
deleteOne(baseId: string, tableId: string, query: object): Promise<import("mongodb").DeleteResult>;
|
|
19
|
+
deleteMany(baseId: string, tableId: string, query: object): Promise<import("mongodb").DeleteResult>;
|
|
20
|
+
getMongodbDataLoader(collectionName: any, fields?: string[]): Promise<any>;
|
|
21
|
+
getTableField(baseId: any, tableId: any, fieldName: any): Promise<{
|
|
22
|
+
type: string;
|
|
23
|
+
name: any;
|
|
24
|
+
reference_to: string;
|
|
25
|
+
} | {
|
|
26
|
+
name: any;
|
|
27
|
+
reference_to: any;
|
|
28
|
+
type?: undefined;
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var TablesService_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.TablesService = void 0;
|
|
14
|
+
require("regenerator-runtime/runtime");
|
|
15
|
+
const common_1 = require("@nestjs/common");
|
|
16
|
+
const mongodb_1 = require("mongodb");
|
|
17
|
+
const uuid_1 = require("uuid");
|
|
18
|
+
const query_mongodb_1 = require("@builder6/query-mongodb");
|
|
19
|
+
const config_1 = require("@nestjs/config");
|
|
20
|
+
const DataLoader = require("dataloader");
|
|
21
|
+
const core_1 = require("@builder6/core");
|
|
22
|
+
let TablesService = TablesService_1 = class TablesService {
|
|
23
|
+
constructor(configService, mongodbService) {
|
|
24
|
+
this.configService = configService;
|
|
25
|
+
this.mongodbService = mongodbService;
|
|
26
|
+
this.loaders = new Map();
|
|
27
|
+
this.logger = new common_1.Logger(TablesService_1.name);
|
|
28
|
+
const mongoUrl = configService.get('tables.mongo.url') || configService.get('mongo.url');
|
|
29
|
+
const client = new mongodb_1.MongoClient(mongoUrl, {});
|
|
30
|
+
client
|
|
31
|
+
.connect()
|
|
32
|
+
.then(() => {
|
|
33
|
+
this.db = client.db();
|
|
34
|
+
this.logger.log('Connected to Tables MongoDB');
|
|
35
|
+
})
|
|
36
|
+
.catch((err) => {
|
|
37
|
+
this.logger.error('Error connecting to Tables MongoDB', err);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
getCollection(baseId, tableId) {
|
|
41
|
+
const collectionName = `t_${baseId}_${tableId}`;
|
|
42
|
+
return this.db.collection(collectionName);
|
|
43
|
+
}
|
|
44
|
+
async createRecord(baseId, tableId, data) {
|
|
45
|
+
const collection = this.getCollection(baseId, tableId);
|
|
46
|
+
const entry = { _id: (0, uuid_1.v4)(), ...data };
|
|
47
|
+
await collection.insertOne(entry);
|
|
48
|
+
return entry;
|
|
49
|
+
}
|
|
50
|
+
async getRecords(baseId, tableId, loadOptions, processingOptions) {
|
|
51
|
+
const collection = this.getCollection(baseId, tableId);
|
|
52
|
+
const result = await (0, query_mongodb_1.querySimple)(collection, loadOptions, {
|
|
53
|
+
replaceIds: false,
|
|
54
|
+
...processingOptions,
|
|
55
|
+
});
|
|
56
|
+
const records = result.data;
|
|
57
|
+
const expands = loadOptions?.expands || [];
|
|
58
|
+
console.log('query expand fields', expands);
|
|
59
|
+
for (const expand of expands) {
|
|
60
|
+
const { reference_to } = await this.getTableField(baseId, tableId, expand);
|
|
61
|
+
console.log('query expand fields', expand, reference_to);
|
|
62
|
+
if (reference_to) {
|
|
63
|
+
const loader = await this.getMongodbDataLoader(reference_to, [
|
|
64
|
+
'_id',
|
|
65
|
+
'name',
|
|
66
|
+
]);
|
|
67
|
+
for (const record of records) {
|
|
68
|
+
if (record[expand]) {
|
|
69
|
+
const expandedRecord = (await loader.load(record[expand])) || {
|
|
70
|
+
_id: expand,
|
|
71
|
+
};
|
|
72
|
+
console.log('expandedRecord', expand, expandedRecord);
|
|
73
|
+
record[expand] = expandedRecord;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
...result,
|
|
80
|
+
data: records,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
async find(baseId, tableId, query, options = {}) {
|
|
84
|
+
const collection = this.getCollection(baseId, tableId);
|
|
85
|
+
return await collection.find(query, options).toArray();
|
|
86
|
+
}
|
|
87
|
+
async findOne(baseId, tableId, query) {
|
|
88
|
+
const collection = this.getCollection(baseId, tableId);
|
|
89
|
+
return await collection.findOne(query);
|
|
90
|
+
}
|
|
91
|
+
async updateRecord(baseId, tableId, id, data) {
|
|
92
|
+
const collection = this.getCollection(baseId, tableId);
|
|
93
|
+
const result = await collection.findOneAndUpdate({ _id: id }, { $set: data }, { returnDocument: 'after' });
|
|
94
|
+
return result.value;
|
|
95
|
+
}
|
|
96
|
+
async deleteOne(baseId, tableId, query) {
|
|
97
|
+
const collection = this.getCollection(baseId, tableId);
|
|
98
|
+
const result = await collection.deleteOne(query);
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
async deleteMany(baseId, tableId, query) {
|
|
102
|
+
const collection = this.getCollection(baseId, tableId);
|
|
103
|
+
const result = await collection.deleteMany(query);
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
async getMongodbDataLoader(collectionName, fields = ['_id', 'name']) {
|
|
107
|
+
if (this.loaders.has(collectionName)) {
|
|
108
|
+
return this.loaders.get(collectionName);
|
|
109
|
+
}
|
|
110
|
+
const fieldsProjection = fields.reduce((acc, field) => {
|
|
111
|
+
acc[field] = 1;
|
|
112
|
+
return acc;
|
|
113
|
+
}, {});
|
|
114
|
+
const loader = new DataLoader(async (ids) => {
|
|
115
|
+
const records = await this.mongodbService.find(collectionName, {
|
|
116
|
+
_id: {
|
|
117
|
+
$in: ids,
|
|
118
|
+
},
|
|
119
|
+
}, {
|
|
120
|
+
projection: fieldsProjection,
|
|
121
|
+
});
|
|
122
|
+
const result = ids.map((id) => records.find((record) => record._id === id));
|
|
123
|
+
return result;
|
|
124
|
+
});
|
|
125
|
+
this.loaders.set(collectionName, loader);
|
|
126
|
+
return loader;
|
|
127
|
+
}
|
|
128
|
+
async getTableField(baseId, tableId, fieldName) {
|
|
129
|
+
if (fieldName === 'created_by' || fieldName === 'modified_by') {
|
|
130
|
+
return {
|
|
131
|
+
type: 'lookup',
|
|
132
|
+
name: fieldName,
|
|
133
|
+
reference_to: 'users',
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
name: fieldName,
|
|
138
|
+
reference_to: null,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
exports.TablesService = TablesService;
|
|
143
|
+
exports.TablesService = TablesService = TablesService_1 = __decorate([
|
|
144
|
+
(0, common_1.Injectable)(),
|
|
145
|
+
__metadata("design:paramtypes", [config_1.ConfigService,
|
|
146
|
+
core_1.MongodbService])
|
|
147
|
+
], TablesService);
|
|
148
|
+
//# sourceMappingURL=tables.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tables.service.js","sourceRoot":"","sources":["../../src/tables/tables.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,uCAAqC;AAErC,2CAAoD;AACpD,qCAAsD;AACtD,+BAAoC;AACpC,2DAAmE;AACnE,2CAA+C;AAC/C,yCAAyC;AACzC,yCAAgD;AAGzC,IAAM,aAAa,qBAAnB,MAAM,aAAa;IAKxB,YACU,aAA4B,EACnB,cAA8B;QADvC,kBAAa,GAAb,aAAa,CAAe;QACnB,mBAAc,GAAd,cAAc,CAAgB;QALzC,YAAO,GAAqB,IAAI,GAAG,EAAE,CAAC;QAC7B,WAAM,GAAG,IAAI,eAAM,CAAC,eAAa,CAAC,IAAI,CAAC,CAAC;QAMvD,MAAM,QAAQ,GAC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SAAS;YACf,YAAY,EAAE,IAAI;SACnB,CAAC;IACJ,CAAC;CACF,CAAA;AA5KY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAOc,sBAAa;QACH,qBAAc;GAPtC,aAAa,CA4KzB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@builder6/tables",
|
|
3
|
+
"version": "0.6.1",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "rm -rf dist && tsc",
|
|
11
|
+
"build:watch": "rm -rf dist && tsc --watch"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@builder6/core": "^0.6.1",
|
|
15
|
+
"dataloader": "^2.2.3",
|
|
16
|
+
"nodemailer": "^6.9.16"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"gitHead": "2f816481fc81096a973e75ed27ff9b8bb0638e0c"
|
|
22
|
+
}
|