namirasoft-field-node 1.3.16 → 1.3.18
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/dist/controller/NSFListController.d.ts +3 -3
- package/dist/controller/NSFListController.js +11 -11
- package/dist/controller/NSFListController.js.map +1 -1
- package/dist/database/FieldDatabaseTables.js +3 -0
- package/dist/database/FieldDatabaseTables.js.map +1 -1
- package/package.json +1 -1
- package/src/controller/NSFListController.ts +11 -11
- package/src/database/FieldDatabaseTables.ts +5 -0
|
@@ -2,12 +2,12 @@ import { Includeable, WhereOptions } from "sequelize";
|
|
|
2
2
|
import { FieldDatabaseTables } from "../database/FieldDatabaseTables";
|
|
3
3
|
import { BaseMySqlDatabase } from "namirasoft-node-mysql";
|
|
4
4
|
export declare class NSFListController {
|
|
5
|
-
static handle_getTables(tables: {
|
|
5
|
+
static handle_getTables(name: string, tables: {
|
|
6
6
|
[table: string]: string[];
|
|
7
|
-
}
|
|
7
|
+
}): {
|
|
8
8
|
[table: string]: string[];
|
|
9
9
|
};
|
|
10
|
-
static handle_getIncludes<D extends BaseMySqlDatabase>(includes: Includeable[], conditions: {
|
|
10
|
+
static handle_getIncludes<D extends BaseMySqlDatabase>(name: string, includes: Includeable[], conditions: {
|
|
11
11
|
[table: string]: WhereOptions[];
|
|
12
12
|
}, tables: FieldDatabaseTables<D>): Includeable[];
|
|
13
13
|
}
|
|
@@ -3,33 +3,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NSFListController = void 0;
|
|
4
4
|
const sequelize_1 = require("sequelize");
|
|
5
5
|
class NSFListController {
|
|
6
|
-
static handle_getTables(
|
|
6
|
+
static handle_getTables(name, tables) {
|
|
7
7
|
let ans = Object.assign({}, tables);
|
|
8
8
|
ans[name] = [];
|
|
9
|
-
ans[
|
|
10
|
-
ans[
|
|
11
|
-
ans[
|
|
9
|
+
ans[`${name}_category`] = [`${name}.id`, `${name}_category.entity_id`];
|
|
10
|
+
ans[`${name}_field`] = [`${name}.id`, `${name}_field.entity_id`];
|
|
11
|
+
ans[`${name}_tag`] = [`${name}.id`, `${name}_tag.entity_id`];
|
|
12
12
|
return ans;
|
|
13
13
|
}
|
|
14
|
-
static handle_getIncludes(includes, conditions, tables) {
|
|
14
|
+
static handle_getIncludes(name, includes, conditions, tables) {
|
|
15
15
|
let ans = [...includes];
|
|
16
|
-
if (conditions[
|
|
16
|
+
if (conditions[`${name}_category`].length > 0)
|
|
17
17
|
ans.push({
|
|
18
18
|
model: tables.entity_category.model,
|
|
19
19
|
attributes: [],
|
|
20
|
-
where: { [sequelize_1.Op.and]: conditions[
|
|
20
|
+
where: { [sequelize_1.Op.and]: conditions[`${name}_category`] }
|
|
21
21
|
});
|
|
22
|
-
if (conditions[
|
|
22
|
+
if (conditions[`${name}_field`].length > 0)
|
|
23
23
|
ans.push({
|
|
24
24
|
model: tables.entity_field.model,
|
|
25
25
|
attributes: [],
|
|
26
|
-
where: { [sequelize_1.Op.and]: conditions[
|
|
26
|
+
where: { [sequelize_1.Op.and]: conditions[`${name}_field`] }
|
|
27
27
|
});
|
|
28
|
-
if (conditions[
|
|
28
|
+
if (conditions[`${name}_tag`].length > 0)
|
|
29
29
|
ans.push({
|
|
30
30
|
model: tables.entity_tag.model,
|
|
31
31
|
attributes: [],
|
|
32
|
-
where: { [sequelize_1.Op.and]: conditions[
|
|
32
|
+
where: { [sequelize_1.Op.and]: conditions[`${name}_tag`] }
|
|
33
33
|
});
|
|
34
34
|
return ans;
|
|
35
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NSFListController.js","sourceRoot":"","sources":["../../src/controller/NSFListController.ts"],"names":[],"mappings":";;;AAAA,yCAA+B;AAK/B,MAAa,iBAAiB;IAE1B,MAAM,CAAC,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"NSFListController.js","sourceRoot":"","sources":["../../src/controller/NSFListController.ts"],"names":[],"mappings":";;;AAAA,yCAA+B;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,CAAC,EAAE;aACnD,CAAC,CAAC;QACP,IAAI,UAAU,CAAC,GAAG,IAAI,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC;YACpC,GAAG,CAAC,IAAI,CAAC;gBACL,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK;gBAC9B,UAAU,EAAE,EAAE;gBACd,KAAK,EAAE,EAAE,CAAC,cAAE,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,GAAG,IAAI,MAAM,CAAC,EAAE;aACjD,CAAC,CAAC;QACP,OAAO,GAAG,CAAC;IACf,CAAC;CACJ;AAlCD,8CAkCC"}
|
|
@@ -18,12 +18,15 @@ class FieldDatabaseTables {
|
|
|
18
18
|
this.entity_category.define(this.name + "_category", EntityCategoryAttributes_1.EntityCategoryAttributes);
|
|
19
19
|
this.entity_field.define(this.name + "_field", EntityFieldAttributes_1.EntityFieldAttributes);
|
|
20
20
|
this.entity_tag.define(this.name + "_tag", EntityTagAttributes_1.EntityTagAttributes);
|
|
21
|
+
model.hasMany(this.entity_tag.model);
|
|
21
22
|
this.entity_tag.model.belongsTo(model, {
|
|
22
23
|
foreignKey: { name: "entity_id", allowNull: false },
|
|
23
24
|
});
|
|
25
|
+
model.hasMany(this.entity_field.model);
|
|
24
26
|
this.entity_field.model.belongsTo(model, {
|
|
25
27
|
foreignKey: { name: "entity_id", allowNull: false },
|
|
26
28
|
});
|
|
29
|
+
model.hasMany(this.entity_category.model);
|
|
27
30
|
this.entity_category.model.belongsTo(model, {
|
|
28
31
|
foreignKey: { name: "entity_id", allowNull: false },
|
|
29
32
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldDatabaseTables.js","sourceRoot":"","sources":["../../src/database/FieldDatabaseTables.ts"],"names":[],"mappings":";;;AACA,qEAAkE;AAClE,+DAA4D;AAC5D,2DAAwD;AAExD,0EAAuE;AACvE,8EAA2E;AAC3E,oFAAiF;AAGjF,MAAa,mBAAmB;IAM5B,YAAY,GAAiC,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irasoft-node-mysql";
|
|
|
5
5
|
|
|
6
6
|
export class NSFListController
|
|
7
7
|
{
|
|
8
|
-
static handle_getTables(tables: { [table: string]: string[]; }
|
|
8
|
+
static handle_getTables(name: string, tables: { [table: string]: string[]; }): { [table: string]: string[]; }
|
|
9
9
|
{
|
|
10
10
|
let ans = { ...tables };
|
|
11
11
|
ans[name] = [];
|
|
12
|
-
ans[
|
|
13
|
-
ans[
|
|
14
|
-
ans[
|
|
12
|
+
ans[`${name}_category`] = [`${name}.id`, `${name}_category.entity_id`];
|
|
13
|
+
ans[`${name}_field`] = [`${name}.id`, `${name}_field.entity_id`];
|
|
14
|
+
ans[`${name}_tag`] = [`${name}.id`, `${name}_tag.entity_id`];
|
|
15
15
|
return ans;
|
|
16
16
|
}
|
|
17
|
-
static handle_getIncludes<D extends BaseMySqlDatabase>(includes: Includeable[], conditions: { [table: string]: WhereOptions[]; }, tables: FieldDatabaseTables<D>): Includeable[]
|
|
17
|
+
static handle_getIncludes<D extends BaseMySqlDatabase>(name: string, includes: Includeable[], conditions: { [table: string]: WhereOptions[]; }, tables: FieldDatabaseTables<D>): Includeable[]
|
|
18
18
|
{
|
|
19
19
|
let ans = [...includes];
|
|
20
|
-
if (conditions[
|
|
20
|
+
if (conditions[`${name}_category`].length > 0)
|
|
21
21
|
ans.push({
|
|
22
22
|
model: tables.entity_category.model,
|
|
23
23
|
attributes: [],
|
|
24
|
-
where: { [Op.and]: conditions[
|
|
24
|
+
where: { [Op.and]: conditions[`${name}_category`] }
|
|
25
25
|
});
|
|
26
|
-
if (conditions[
|
|
26
|
+
if (conditions[`${name}_field`].length > 0)
|
|
27
27
|
ans.push({
|
|
28
28
|
model: tables.entity_field.model,
|
|
29
29
|
attributes: [],
|
|
30
|
-
where: { [Op.and]: conditions[
|
|
30
|
+
where: { [Op.and]: conditions[`${name}_field`] }
|
|
31
31
|
});
|
|
32
|
-
if (conditions[
|
|
32
|
+
if (conditions[`${name}_tag`].length > 0)
|
|
33
33
|
ans.push({
|
|
34
34
|
model: tables.entity_tag.model,
|
|
35
35
|
attributes: [],
|
|
36
|
-
where: { [Op.and]: conditions[
|
|
36
|
+
where: { [Op.and]: conditions[`${name}_tag`] }
|
|
37
37
|
});
|
|
38
38
|
return ans;
|
|
39
39
|
}
|
|
@@ -28,12 +28,17 @@ export class FieldDatabaseTables<Database extends BaseMySqlDatabase>
|
|
|
28
28
|
this.entity_tag.define(this.name + "_tag", EntityTagAttributes);
|
|
29
29
|
|
|
30
30
|
// set foreignKeys
|
|
31
|
+
model.hasMany(this.entity_tag.model);
|
|
31
32
|
this.entity_tag.model.belongsTo(model, {
|
|
32
33
|
foreignKey: { name: "entity_id", allowNull: false },
|
|
33
34
|
});
|
|
35
|
+
|
|
36
|
+
model.hasMany(this.entity_field.model);
|
|
34
37
|
this.entity_field.model.belongsTo(model, {
|
|
35
38
|
foreignKey: { name: "entity_id", allowNull: false },
|
|
36
39
|
});
|
|
40
|
+
|
|
41
|
+
model.hasMany(this.entity_category.model);
|
|
37
42
|
this.entity_category.model.belongsTo(model, {
|
|
38
43
|
foreignKey: { name: "entity_id", allowNull: false },
|
|
39
44
|
});
|