jcc-express-mvc 1.2.9 → 1.3.0

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.
Files changed (57) hide show
  1. package/index.d.ts +0 -4
  2. package/index.d.ts.map +1 -1
  3. package/index.js +1 -5
  4. package/lib/Request/FormRequest.d.ts +4 -4
  5. package/lib/Request/FormRequest.d.ts.map +1 -1
  6. package/package.json +1 -1
  7. package/lib/Database/src/BaseEntity.d.ts +0 -67
  8. package/lib/Database/src/BaseEntity.d.ts.map +0 -1
  9. package/lib/Database/src/BaseEntity.js +0 -208
  10. package/lib/Database/src/BaseModel.d.ts +0 -22
  11. package/lib/Database/src/BaseModel.d.ts.map +0 -1
  12. package/lib/Database/src/BaseModel.js +0 -44
  13. package/lib/Database/src/Builder.d.ts +0 -232
  14. package/lib/Database/src/Builder.d.ts.map +0 -1
  15. package/lib/Database/src/Builder.js +0 -430
  16. package/lib/Database/src/Cast/index.d.ts +0 -12
  17. package/lib/Database/src/Cast/index.d.ts.map +0 -1
  18. package/lib/Database/src/Cast/index.js +0 -98
  19. package/lib/Database/src/Cast/types.d.ts +0 -17
  20. package/lib/Database/src/Cast/types.d.ts.map +0 -1
  21. package/lib/Database/src/Cast/types.js +0 -25
  22. package/lib/Database/src/Date/index.d.ts +0 -11
  23. package/lib/Database/src/Date/index.d.ts.map +0 -1
  24. package/lib/Database/src/Date/index.js +0 -36
  25. package/lib/Database/src/Model.d.ts +0 -26
  26. package/lib/Database/src/Model.d.ts.map +0 -1
  27. package/lib/Database/src/Model.js +0 -53
  28. package/lib/Database/src/Query.d.ts +0 -7
  29. package/lib/Database/src/Query.d.ts.map +0 -1
  30. package/lib/Database/src/Query.js +0 -16
  31. package/lib/Database/src/QueryBuilder.d.ts +0 -235
  32. package/lib/Database/src/QueryBuilder.d.ts.map +0 -1
  33. package/lib/Database/src/QueryBuilder.js +0 -354
  34. package/lib/Database/src/QueryInstance.d.ts +0 -8
  35. package/lib/Database/src/QueryInstance.d.ts.map +0 -1
  36. package/lib/Database/src/QueryInstance.js +0 -28
  37. package/lib/Database/src/RelationBuilder.d.ts +0 -26
  38. package/lib/Database/src/RelationBuilder.d.ts.map +0 -1
  39. package/lib/Database/src/RelationBuilder.js +0 -97
  40. package/lib/Database/src/Schema/BaseSchemaEntity/index.d.ts +0 -10
  41. package/lib/Database/src/Schema/BaseSchemaEntity/index.d.ts.map +0 -1
  42. package/lib/Database/src/Schema/BaseSchemaEntity/index.js +0 -26
  43. package/lib/Database/src/Schema/BluePrint/index.d.ts +0 -168
  44. package/lib/Database/src/Schema/BluePrint/index.d.ts.map +0 -1
  45. package/lib/Database/src/Schema/BluePrint/index.js +0 -257
  46. package/lib/Database/src/Schema/index.d.ts +0 -6
  47. package/lib/Database/src/Schema/index.d.ts.map +0 -1
  48. package/lib/Database/src/Schema/index.js +0 -18
  49. package/lib/Database/src/db/connection.d.ts +0 -5
  50. package/lib/Database/src/db/connection.d.ts.map +0 -1
  51. package/lib/Database/src/db/connection.js +0 -22
  52. package/lib/Database/src/type.d.ts +0 -18
  53. package/lib/Database/src/type.d.ts.map +0 -1
  54. package/lib/Database/src/type.js +0 -2
  55. package/lib/Database/src/utils/index.d.ts +0 -45
  56. package/lib/Database/src/utils/index.d.ts.map +0 -1
  57. package/lib/Database/src/utils/index.js +0 -112
package/index.d.ts CHANGED
@@ -4,8 +4,6 @@ import Authentication from "./lib/Auth";
4
4
  import { AppRequest, AppResponse, AppNext } from "./lib/Interface";
5
5
  import { FormRequest as AppFormRequest } from "./lib/Request/FormRequest";
6
6
  import { bcrypt as appBcrypt, verifyHash as appVerifyHash, jwtSign as appJwtSign, jwtVerify as appjwtVerify } from "./lib/util";
7
- import { Schema as AppSchema } from "./lib/Database/src/Schema";
8
- import { Model as AppModel } from "./lib/Database/src/Model";
9
7
  import { NodeArtisanCommand } from "./lib/Command-Line/NodeArtisanCommand";
10
8
  export declare const Route: import("./lib/Routes/Router").Router<any>;
11
9
  export declare const ApiRoute: import("./lib/Routes/Router").Router<any>;
@@ -20,8 +18,6 @@ export declare const bcrypt: typeof appBcrypt;
20
18
  export declare const jwtSign: typeof appJwtSign;
21
19
  export declare const jwtVerify: typeof appjwtVerify;
22
20
  export declare const verifyHash: typeof appVerifyHash;
23
- export declare const Model: typeof AppModel;
24
- export declare const Schema: typeof AppSchema;
25
21
  export declare const artisanCommand: typeof NodeArtisanCommand;
26
22
  export type Request = AppRequest;
27
23
  export type Response = AppResponse;
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../framework/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAE5C,OAAO,MAAM,MAAM,6BAA6B,CAAC;AACjD,OAAO,cAAc,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EACL,MAAM,IAAI,SAAS,EACnB,UAAU,IAAI,aAAa,EAC3B,OAAO,IAAI,UAAU,EACrB,SAAS,IAAI,YAAY,EAC1B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAE3E,eAAO,MAAM,KAAK,2CAAkB,CAAC;AACrC,eAAO,MAAM,QAAQ,2CAAkB,CAAC;AACxC,eAAO,MAAM,MAAM,KAAmB,CAAC;AACvC,eAAO,MAAM,UAAU,eAAS,CAAC;AACjC,eAAO,MAAM,MAAM,EAAE,OAAO,SAAqB,CAAC;AAClD,eAAO,MAAM,IAAI,EAAE,OAAO,cAA+B,CAAC;AAC1D,eAAO,MAAM,IAA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,eAAS,CAAC;AACjC,eAAO,MAAM,MAAM,EAAE,OAAO,SAAqB,CAAC;AAClD,eAAO,MAAM,IAAI,EAAE,OAAO,cAA+B,CAAC;AAC1D,eAAO,MAAM,IAAI,oEAAsB,CAAC;AACxC,eAAO,MAAM,OAAO,oEAAyB,CAAC;AAC9C,eAAO,MAAM,WAAW,EAAE,OAAO,cAA+B,CAAC;AACjE,eAAO,MAAM,MAAM,EAAE,OAAO,SAAqB,CAAC;AAClD,eAAO,MAAM,OAAO,EAAE,OAAO,UAAuB,CAAC;AACrD,eAAO,MAAM,SAAS,EAAE,OAAO,YAA2B,CAAC;AAC3D,eAAO,MAAM,UAAU,EAAE,OAAO,aAA6B,CAAC;AAC9D,eAAO,MAAM,cAAc,EAAE,OAAO,kBAAuC,CAAC;AAG5E,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC;AACjC,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAC;AACnC,MAAM,MAAM,IAAI,GAAG,OAAO,CAAC"}
package/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.artisanCommand = exports.Schema = exports.Model = exports.verifyHash = exports.jwtVerify = exports.jwtSign = exports.bcrypt = exports.FormRequest = exports.apiAuth = exports.auth = exports.Auth = exports.config = exports.HttpKernel = exports.server = exports.ApiRoute = exports.Route = void 0;
6
+ exports.artisanCommand = exports.verifyHash = exports.jwtVerify = exports.jwtSign = exports.bcrypt = exports.FormRequest = exports.apiAuth = exports.auth = exports.Auth = exports.config = exports.HttpKernel = exports.server = exports.ApiRoute = exports.Route = void 0;
7
7
  const Config_1 = __importDefault(require("./lib/Config/Config"));
8
8
  const App_1 = require("./lib/App");
9
9
  const HttpKernel_1 = __importDefault(require("./lib/HttpKernel/HttpKernel"));
@@ -11,8 +11,6 @@ const Auth_1 = __importDefault(require("./lib/Auth"));
11
11
  const AuthMiddleware_1 = require("./lib/Auth/AuthMiddleware");
12
12
  const FormRequest_1 = require("./lib/Request/FormRequest");
13
13
  const util_1 = require("./lib/util");
14
- const Schema_1 = require("./lib/Database/src/Schema");
15
- const Model_1 = require("./lib/Database/src/Model");
16
14
  const NodeArtisanCommand_1 = require("./lib/Command-Line/NodeArtisanCommand");
17
15
  exports.Route = App_1.app.webRoutes();
18
16
  exports.ApiRoute = App_1.app.apiRoutes();
@@ -27,6 +25,4 @@ exports.bcrypt = util_1.bcrypt;
27
25
  exports.jwtSign = util_1.jwtSign;
28
26
  exports.jwtVerify = util_1.jwtVerify;
29
27
  exports.verifyHash = util_1.verifyHash;
30
- exports.Model = Model_1.Model;
31
- exports.Schema = Schema_1.Schema;
32
28
  exports.artisanCommand = NodeArtisanCommand_1.NodeArtisanCommand;
@@ -1,4 +1,4 @@
1
- import { objType } from "@framework/lib/Database/src/type";
1
+ import { ObjectType } from "../Type";
2
2
  import { AppRequest } from "../Interface";
3
3
  export declare class FormRequest {
4
4
  protected req: AppRequest;
@@ -19,18 +19,18 @@ export declare class FormRequest {
19
19
  * Retrieves the request body.
20
20
  * @returns {Object} - Request body object.
21
21
  */
22
- protected request(): objType;
22
+ protected request(): ObjectType;
23
23
  /**
24
24
  * Validates form data using the validation method provided by the request object.
25
25
  * @param {Object} formData - Data to be validated.
26
26
  * @returns {Promise} - Promise resolving with validation result.
27
27
  */
28
- protected validate(formData: objType): Promise<Record<any, objType>>;
28
+ protected validate(formData: ObjectType): Promise<Record<any, ObjectType>>;
29
29
  /**
30
30
  * Validates API data using the validation method provided by the request object.
31
31
  * @param {Object} formData - Data to be validated.
32
32
  * @returns {Promise} - Promise resolving with validation result.
33
33
  */
34
- protected apiValidate(formData: objType): Promise<Record<any, objType>>;
34
+ protected apiValidate(formData: ObjectType): Promise<Record<any, ObjectType>>;
35
35
  }
36
36
  //# sourceMappingURL=FormRequest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FormRequest.d.ts","sourceRoot":"","sources":["../../../framework/lib/Request/FormRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,qBAAa,WAAW;IACtB,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC;gBACd,GAAG,EAAE,UAAU;IAO3B;;;;OAIG;IACH,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG;IAIlC;;;;OAIG;IACH,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAIrC;;;OAGG;IACH,SAAS,CAAC,OAAO,IAAI,OAAO;IAI5B;;;;OAIG;cACa,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAI1E;;;;OAIG;cACa,WAAW,CACzB,QAAQ,EAAE,OAAO,GAChB,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAGjC"}
1
+ {"version":3,"file":"FormRequest.d.ts","sourceRoot":"","sources":["../../../framework/lib/Request/FormRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,qBAAa,WAAW;IACtB,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC;gBACd,GAAG,EAAE,UAAU;IAO3B;;;;OAIG;IACH,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG;IAIlC;;;;OAIG;IACH,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAIrC;;;OAGG;IACH,SAAS,CAAC,OAAO,IAAI,UAAU;IAI/B;;;;OAIG;cACa,QAAQ,CACtB,QAAQ,EAAE,UAAU,GACnB,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAInC;;;;OAIG;cACa,WAAW,CACzB,QAAQ,EAAE,UAAU,GACnB,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;CAGpC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jcc-express-mvc",
3
- "version": "1.2.9",
3
+ "version": "1.3.0",
4
4
  "description": "express mvc structure",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1,67 +0,0 @@
1
- import { objType } from "./type";
2
- import { Database } from "./db/connection";
3
- import { QueryInstance } from "./QueryInstance";
4
- export declare class BaseEntity extends Database {
5
- protected attributes: objType;
6
- protected _select: string | Array<string>;
7
- protected _tableName: string;
8
- protected _where: Array<any>;
9
- protected _joins: Array<any>;
10
- protected _orderBy?: string;
11
- protected _limit?: string | number;
12
- protected _offset?: string | number;
13
- protected _groupBy?: string;
14
- protected _having?: string;
15
- protected _distinct: boolean;
16
- protected _insertData: {
17
- keys: Array<any>;
18
- values: Array<any>;
19
- };
20
- protected _updateData: objType;
21
- protected _delete?: boolean;
22
- protected _count?: boolean;
23
- protected _relationships: Array<any>;
24
- protected fillable: Array<string>;
25
- protected guard: Array<string>;
26
- protected hidden: Array<string>;
27
- protected casts?: object;
28
- protected _max: string;
29
- protected _min: string;
30
- protected _sum: string;
31
- protected _avg: string;
32
- protected sqlQuery: string;
33
- /**
34
- * Resets all query builder state variables to their default values.
35
- */
36
- _resetQuery(): void;
37
- /**
38
- * Constructs and returns the SQL query based on the current query builder state.
39
- *
40
- * @returns {string} The generated SQL query.
41
- */
42
- private compileToSql;
43
- private buidInsert;
44
- private buildUpdate;
45
- private buildJoin;
46
- private buildOffset;
47
- private buildselect;
48
- private buildDelete;
49
- private buildWhere;
50
- private buildCount;
51
- private buildMin;
52
- private buildMax;
53
- private buildAvg;
54
- private buildSum;
55
- private buildHaving;
56
- private buildGroup;
57
- private buildOrderBy;
58
- private buildLimit;
59
- protected getCompileSqlCode(): string;
60
- setGuard(values: Array<string>): void;
61
- setFillable(values: Array<string>): void;
62
- setHidden(values: Array<string>): void;
63
- setCasts(values: objType): void;
64
- private removeHiddenValues;
65
- protected newInstance<T>(results: objType): QueryInstance<T>;
66
- }
67
- //# sourceMappingURL=BaseEntity.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BaseEntity.d.ts","sourceRoot":"","sources":["../../../../framework/lib/Database/src/BaseEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,qBAAa,UAAW,SAAQ,QAAQ;IACtC,SAAS,CAAC,UAAU,EAAE,OAAO,CAAM;IACnC,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAO;IAChD,SAAS,CAAC,UAAU,EAAE,MAAM,CAAM;IAClC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAM;IAClC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAM;IAClC,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACnC,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpC,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,SAAS,EAAE,OAAO,CAAS;IACrC,SAAS,CAAC,WAAW,EAAE;QAAE,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;KAAE,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AAI;IAIrC,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI;IAIxC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI;IAItC,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAItC,OAAO,CAAC,kBAAkB;IAS1B,SAAS,CAAC,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,aAAa,CAAC,CAAC,CAAC;CAQ7D"}
@@ -1,208 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseEntity = void 0;
4
- const connection_1 = require("./db/connection");
5
- const QueryInstance_1 = require("./QueryInstance");
6
- const Cast_1 = require("./Cast");
7
- class BaseEntity extends connection_1.Database {
8
- constructor() {
9
- super(...arguments);
10
- this.attributes = {};
11
- this._select = "*";
12
- this._tableName = "";
13
- this._where = [];
14
- this._joins = [];
15
- this._distinct = false;
16
- this._insertData = {
17
- keys: [],
18
- values: [],
19
- };
20
- this._updateData = {}; //{ keys: Array<any>; values: Array<any> };
21
- this._relationships = [];
22
- this.fillable = [];
23
- this.guard = [];
24
- this.hidden = [];
25
- this._max = "";
26
- this._min = "";
27
- this._sum = "";
28
- this._avg = "";
29
- this.sqlQuery = "";
30
- }
31
- /**
32
- * Resets all query builder state variables to their default values.
33
- */
34
- _resetQuery() {
35
- this._select = "*";
36
- this._tableName = "";
37
- this._where = [];
38
- this._joins = [];
39
- this._orderBy = "";
40
- this._limit = "";
41
- this._offset = "";
42
- this._groupBy = "";
43
- this._having = "";
44
- this._distinct = false;
45
- this._insertData = { keys: [], values: [] };
46
- this._updateData = {};
47
- this._delete = false;
48
- this._count = false;
49
- this._relationships = [];
50
- this._max = "";
51
- this._min = "";
52
- this._sum = "";
53
- this._avg = "";
54
- return;
55
- }
56
- /**
57
- * Constructs and returns the SQL query based on the current query builder state.
58
- *
59
- * @returns {string} The generated SQL query.
60
- */
61
- compileToSql() {
62
- if (this._count) {
63
- this.sqlQuery += this.buildCount();
64
- }
65
- else if (this._sum) {
66
- this.sqlQuery += this.buildSum();
67
- }
68
- else if (this._avg) {
69
- this.sqlQuery += this.buildAvg();
70
- }
71
- else if (this._max) {
72
- this.sqlQuery += this.buildMax();
73
- }
74
- else if (this._min) {
75
- this.sqlQuery += this.buildMin();
76
- }
77
- else if (Object.values(this._insertData.keys).length > 1) {
78
- this.sqlQuery += this.buidInsert();
79
- }
80
- else if (Object.values(this._updateData).length > 1) {
81
- this.sqlQuery += this.buildUpdate();
82
- }
83
- else if (this._delete) {
84
- this.sqlQuery += this.buildDelete();
85
- }
86
- else {
87
- this.sqlQuery += this.buildselect();
88
- }
89
- if (this._joins.length > 0) {
90
- this.sqlQuery += this.buildJoin();
91
- }
92
- if (this._where.length > 0) {
93
- this.sqlQuery += this.buildWhere();
94
- }
95
- if (this._groupBy) {
96
- this.sqlQuery += this.buildGroup();
97
- }
98
- if (this._having) {
99
- this.sqlQuery += this.buildHaving();
100
- }
101
- if (this._orderBy) {
102
- this.sqlQuery += this.buildOrderBy();
103
- }
104
- if (this._limit) {
105
- this.sqlQuery += this.buildLimit();
106
- }
107
- if (this._offset) {
108
- this.sqlQuery += this.buildOffset();
109
- }
110
- }
111
- buidInsert() {
112
- return `INSERT INTO ${this._tableName} (${this._insertData.keys.join(",")}) VALUES (${this._insertData.values.join(", ")})`;
113
- }
114
- buildUpdate() {
115
- let updateString = Object.keys(this._updateData)
116
- .map((key) => `${key}='${this._updateData[key]}'`)
117
- .join(", ");
118
- return `UPDATE ${this._tableName} SET ${updateString}`;
119
- }
120
- buildJoin() {
121
- return this._joins
122
- .map((join) => {
123
- ` ${join.type} JOIN ${join.table} ON ${join.firstColumn} ${join.operator} ${join.secondColumn}`;
124
- })
125
- .join();
126
- }
127
- // private buildSelect(): string {}
128
- buildOffset() {
129
- return ` OFFSET ${this._offset}`;
130
- }
131
- buildselect() {
132
- return `SELECT ${this._distinct ? "DISTINCT " : ""}${this._select} FROM ${this._tableName}`;
133
- }
134
- buildDelete() {
135
- return `DELETE FROM ${this._tableName}`;
136
- }
137
- buildWhere() {
138
- return (" WHERE " +
139
- this._where
140
- .map((condition, index) => {
141
- const connector = index > 0 && condition.connector
142
- ? ` ${condition.connector} `
143
- : index > 0
144
- ? " AND "
145
- : "";
146
- return `${connector}${condition.column} ${condition.operator} '${condition.value}'`;
147
- })
148
- .join(""));
149
- }
150
- buildCount() {
151
- return `SELECT COUNT(*) as count FROM ${this._tableName}`;
152
- }
153
- buildMin() {
154
- return `SELECT MIN(${this._min}) FROM ${this._tableName}`;
155
- }
156
- buildMax() {
157
- return `SELECT MAX(${this._max}) FROM ${this._tableName} `;
158
- }
159
- buildAvg() {
160
- return `SELECT MAX(${this._avg}) FROM ${this._tableName} `;
161
- }
162
- buildSum() {
163
- return `SELECT SUM(${this._sum}) FROM ${this._tableName} `;
164
- }
165
- buildHaving() {
166
- return ` HAVING ${this._having}`;
167
- }
168
- buildGroup() {
169
- return ` GROUP BY ${this._groupBy}`;
170
- }
171
- buildOrderBy() {
172
- return ` ORDER BY ${this._orderBy}`;
173
- }
174
- buildLimit() {
175
- return ` LIMIT ${this._limit}`;
176
- }
177
- getCompileSqlCode() {
178
- this.compileToSql();
179
- // this._resetQuery();
180
- let sql = this.sqlQuery;
181
- this.sqlQuery = "";
182
- return sql;
183
- }
184
- setGuard(values) {
185
- this.guard = values;
186
- }
187
- setFillable(values) {
188
- this.fillable = values;
189
- }
190
- setHidden(values) {
191
- this.hidden = values;
192
- }
193
- setCasts(values) {
194
- this.casts = values;
195
- }
196
- removeHiddenValues(item) {
197
- const keysSet = new Set(this.hidden);
198
- const newItem = { ...item };
199
- for (const key of keysSet) {
200
- delete newItem[key];
201
- }
202
- return newItem;
203
- }
204
- newInstance(results) {
205
- return results.map((result) => new QueryInstance_1.QueryInstance(Cast_1.Cast.getCastType(this.casts || {}, this.removeHiddenValues(result))));
206
- }
207
- }
208
- exports.BaseEntity = BaseEntity;
@@ -1,22 +0,0 @@
1
- import { QueryBuilder } from "./QueryBuilder";
2
- export declare class BaseModel extends QueryBuilder {
3
- /**
4
- * Defines a hasMany relationship between the current model and another model.
5
- *
6
- * @param {string} relatedModel - The name of the related model.
7
- * @param {string} foreingKey - The foreign key in the related model (defaults to id).
8
- * @param {string} localKey - The local key in the current model (defaults to 'id').
9
- * @returns {Function} A function that retrieves the related data based on the relationship.
10
- */
11
- protected hasMany(relatedModel: string, foreingKey: string, localKey?: string): any;
12
- /**
13
- * Defines a belongsTo relationship between the current model and another model.
14
- *
15
- * @param {string} relatedModel - The name of the related model.
16
- * @param {string} foreingKey - The foreign key in the related model (defaults to id).
17
- * @param {string} localKey - The local key in the current model (defaults to 'id').
18
- * @returns {Function} A function that retrieves the related data based on the relationship.
19
- */
20
- protected belongsTo(relatedModel: string, foreingKey: string, localKey?: string): any;
21
- }
22
- //# sourceMappingURL=BaseModel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BaseModel.d.ts","sourceRoot":"","sources":["../../../../framework/lib/Database/src/BaseModel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,qBAAa,SAAU,SAAQ,YAAY;IACzC;;;;;;;OAOG;IACH,SAAS,CAAC,OAAO,CACf,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAE,MAAa,GACtB,GAAG;IAWN;;;;;;;OAOG;IACH,SAAS,CAAC,SAAS,CACjB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAE,MAAa,GACtB,GAAG;CAUP"}
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseModel = void 0;
4
- const QueryBuilder_1 = require("./QueryBuilder");
5
- const utils_1 = require("./utils");
6
- class BaseModel extends QueryBuilder_1.QueryBuilder {
7
- /**
8
- * Defines a hasMany relationship between the current model and another model.
9
- *
10
- * @param {string} relatedModel - The name of the related model.
11
- * @param {string} foreingKey - The foreign key in the related model (defaults to id).
12
- * @param {string} localKey - The local key in the current model (defaults to 'id').
13
- * @returns {Function} A function that retrieves the related data based on the relationship.
14
- */
15
- hasMany(relatedModel, foreingKey, localKey = "id") {
16
- return async (query = {}) => {
17
- const result = (0, utils_1.extractFirst)(query);
18
- const value = result[localKey];
19
- return {
20
- results: this.select().table(relatedModel).where(foreingKey, value),
21
- type: "hasMany",
22
- };
23
- };
24
- }
25
- /**
26
- * Defines a belongsTo relationship between the current model and another model.
27
- *
28
- * @param {string} relatedModel - The name of the related model.
29
- * @param {string} foreingKey - The foreign key in the related model (defaults to id).
30
- * @param {string} localKey - The local key in the current model (defaults to 'id').
31
- * @returns {Function} A function that retrieves the related data based on the relationship.
32
- */
33
- belongsTo(relatedModel, foreingKey, localKey = "id") {
34
- return async (query = {}) => {
35
- const result = (0, utils_1.extractFirst)(query);
36
- const value = result[foreingKey];
37
- return {
38
- results: this.select().table(relatedModel).where(localKey, value),
39
- type: "belongsTo",
40
- };
41
- };
42
- }
43
- }
44
- exports.BaseModel = BaseModel;