tspace-mysql 1.1.2 → 1.1.3

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,7 +2,7 @@
2
2
  * The entry point.
3
3
  *
4
4
  * @module tspace-mysql
5
- */
5
+ */
6
6
  import * as tspace from './tspace';
7
7
  export * from './tspace';
8
8
  export default tspace;
package/dist/lib/index.js CHANGED
@@ -30,7 +30,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
30
30
  * The entry point.
31
31
  *
32
32
  * @module tspace-mysql
33
- */
34
- var tspace = __importStar(require("./tspace"));
33
+ */
34
+ const tspace = __importStar(require("./tspace"));
35
35
  __exportStar(require("./tspace"), exports);
36
36
  exports.default = tspace;
@@ -1,31 +1,11 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
18
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
4
  };
20
5
  Object.defineProperty(exports, "__esModule", { value: true });
21
6
  exports.AbstractDB = void 0;
22
- var Database_1 = __importDefault(require("./Database"));
23
- var AbstractDB = /** @class */ (function (_super) {
24
- __extends(AbstractDB, _super);
25
- function AbstractDB() {
26
- return _super !== null && _super.apply(this, arguments) || this;
27
- }
28
- return AbstractDB;
29
- }(Database_1.default));
7
+ const Database_1 = __importDefault(require("./Database"));
8
+ class AbstractDB extends Database_1.default {
9
+ }
30
10
  exports.AbstractDB = AbstractDB;
31
11
  exports.default = AbstractDB;
@@ -8,10 +8,12 @@ declare abstract class AbstractDatabase {
8
8
  protected $db: {
9
9
  get: Function;
10
10
  set: Function;
11
+ clone: Function;
11
12
  };
12
13
  protected $pool: {
13
14
  get: Function;
14
15
  set: Function;
16
+ load: Function;
15
17
  };
16
18
  protected $logger: {
17
19
  get: Function;
@@ -33,10 +35,7 @@ declare abstract class AbstractDatabase {
33
35
  abstract whereId(id: number): void;
34
36
  abstract whereUser(id: number): void;
35
37
  abstract whereEmail(value: string): void;
36
- abstract whereGroupStart(column: string, operator: string, value: string): void;
37
- abstract whereGroupEnd(column: string, operator: string, value: string): void;
38
- abstract orWhereGroupStart(column: string, operator: string, value: string): void;
39
- abstract orWhereGroupEnd(column: string, operator: string, value: string): void;
38
+ abstract whereQuery(callback: Function): void;
40
39
  abstract orWhere(column: string, operator: string, value: string): void;
41
40
  abstract whereIn(column: string, arrayValues: Array<any>): void;
42
41
  abstract orWhereIn(column: string, arrayValues: Array<any>): void;
@@ -82,6 +81,12 @@ declare abstract class AbstractDatabase {
82
81
  page: number;
83
82
  }): Promise<Pagination>;
84
83
  abstract first(): Promise<any>;
84
+ abstract firstOrError(message: string, options?: {
85
+ [key: string]: any;
86
+ }): Promise<any>;
87
+ abstract findOneOrError(message: string, options?: {
88
+ [key: string]: any;
89
+ }): Promise<any>;
85
90
  abstract get(): Promise<any>;
86
91
  abstract findOne(): Promise<any>;
87
92
  abstract findMany(): Promise<any>;
@@ -1,34 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var AbstractDatabase = /** @class */ (function () {
4
- function AbstractDatabase() {
5
- this.$setters = [
6
- '$attributes',
7
- '$logger',
8
- '$utils',
9
- '$constants',
10
- '$pool',
11
- '$db'
12
- ];
13
- this.$utils = {};
14
- this.$constants = function (name) { };
15
- this.$db = {
16
- get: function (key) { },
17
- set: function (key, value) { }
18
- };
19
- this.$pool = {
20
- get: function (sql) { },
21
- set: function (pool) { }
22
- };
23
- this.$logger = {
24
- get: function () { },
25
- set: function (value) { },
26
- check: function (value) {
27
- return true || false;
28
- }
29
- };
30
- this.$attributes = {};
31
- }
32
- return AbstractDatabase;
33
- }());
3
+ class AbstractDatabase {
4
+ $setters = [
5
+ '$attributes',
6
+ '$logger',
7
+ '$utils',
8
+ '$constants',
9
+ '$pool',
10
+ '$db'
11
+ ];
12
+ $utils = {};
13
+ $constants = (name) => { };
14
+ $db = {
15
+ get: (key) => { },
16
+ set: (key, value) => { },
17
+ clone: (data) => { }
18
+ };
19
+ $pool = {
20
+ get: (sql) => { },
21
+ set: (pool) => { },
22
+ load: () => { }
23
+ };
24
+ $logger = {
25
+ get: () => { },
26
+ set: (value) => { },
27
+ check: (value) => true || false
28
+ };
29
+ $attributes = {};
30
+ }
34
31
  exports.default = AbstractDatabase;
@@ -1,21 +1,35 @@
1
- import { Relation } from './Interface';
1
+ import { Relation, RelationQuery } from './Interface';
2
2
  import Database from './Database';
3
3
  declare abstract class AbstractModel extends Database {
4
- abstract useDebug(): void;
5
- abstract useTable(table: string): void;
6
- abstract useTimestamp(): void;
7
- abstract useSoftDelete(): void;
8
- abstract usePattern(pattern: string): void;
9
- abstract onlyTrashed(): void;
10
- abstract trashed(): void;
11
- abstract restore(): void;
12
- abstract with(...nameRelations: string[]): void;
13
- abstract withQuery(nameRelations: string, callback: Function): void;
14
- abstract withExists(...nameRelations: string[]): void;
15
- abstract hasOne({ name, model, localKey, foreignKey, freezeTable, as }: Relation): void;
16
- abstract hasMany({ name, model, localKey, foreignKey, freezeTable, as }: Relation): void;
17
- abstract belongsTo({ name, model, localKey, foreignKey, freezeTable, as }: Relation): void;
18
- abstract belongsToMany({ name, model, localKey, foreignKey, freezeTable, as }: Relation): void;
4
+ abstract useUUID(): this;
5
+ abstract usePrimaryKey(primaryKey: string): this;
6
+ abstract useRegistry(): this;
7
+ abstract useDebug(): this;
8
+ abstract useTable(table: string): this;
9
+ abstract useTablePlural(): this;
10
+ abstract useTableSingular(): this;
11
+ abstract useTimestamp(): this;
12
+ abstract useSoftDelete(): this;
13
+ abstract usePattern(pattern: string): this;
14
+ abstract onlyTrashed(): Promise<any>;
15
+ abstract trashed(): Promise<any>;
16
+ abstract restore(): Promise<any>;
17
+ abstract ignoreSoftDelete(): this;
18
+ abstract disableSoftDelete(): this;
19
+ abstract registry(func: {
20
+ [key: string]: Function;
21
+ }): this;
22
+ abstract with(...nameRelations: string[]): this;
23
+ abstract withQuery(nameRelations: string, callback: Function): this;
24
+ abstract withExists(...nameRelations: string[]): this;
25
+ abstract hasOne({ name, model, localKey, foreignKey, freezeTable, as }: Relation): this;
26
+ abstract hasMany({ name, model, localKey, foreignKey, freezeTable, as }: Relation): this;
27
+ abstract belongsTo({ name, model, localKey, foreignKey, freezeTable, as }: Relation): this;
28
+ abstract belongsToMany({ name, model, localKey, foreignKey, freezeTable, as }: Relation): this;
29
+ abstract hasOneQuery({ name, model, localKey, foreignKey, freezeTable, as }: RelationQuery, callback: Function): this;
30
+ abstract hasManyQuery({ name, model, localKey, foreignKey, freezeTable, as }: RelationQuery, callback: Function): this;
31
+ abstract belongsToQuery({ name, model, localKey, foreignKey, freezeTable, as }: RelationQuery, callback: Function): this;
32
+ abstract belongsToManyQuery({ name, model, localKey, foreignKey, freezeTable, as }: RelationQuery, callback: Function): this;
19
33
  }
20
34
  export { AbstractModel };
21
35
  export default AbstractModel;
@@ -1,31 +1,11 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
18
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
4
  };
20
5
  Object.defineProperty(exports, "__esModule", { value: true });
21
6
  exports.AbstractModel = void 0;
22
- var Database_1 = __importDefault(require("./Database"));
23
- var AbstractModel = /** @class */ (function (_super) {
24
- __extends(AbstractModel, _super);
25
- function AbstractModel() {
26
- return _super !== null && _super.apply(this, arguments) || this;
27
- }
28
- return AbstractModel;
29
- }(Database_1.default));
7
+ const Database_1 = __importDefault(require("./Database"));
8
+ class AbstractModel extends Database_1.default {
9
+ }
30
10
  exports.AbstractModel = AbstractModel;
31
11
  exports.default = AbstractModel;
@@ -1,65 +1,136 @@
1
1
  declare class Blueprint {
2
2
  protected type: string;
3
3
  protected attrbuites: Array<string>;
4
- private _addAssignType;
5
- private _addAssignAttrbuite;
4
+ /**
5
+ * Assign type 'int' in table
6
+ * @return {this} this
7
+ */
6
8
  int(): this;
7
9
  /**
8
- * Assign type
9
- * @param {number}
10
+ * Assign type 'TINYINT' in table
11
+ * @param {number} number
12
+ * @return {this} this
10
13
  */
11
- tinyInt(n?: number): this;
14
+ tinyInt(number?: number): this;
12
15
  /**
13
- * Assign type
14
- * @param {number}
16
+ * Assign type 'BIGINT' in table
17
+ * @param {number} number [number = 10]
18
+ * @return {this} this
15
19
  */
16
- bigInt(n?: number): this;
20
+ bigInt(number?: number): this;
17
21
  /**
18
- * Assign type
22
+ * Assign type 'DOUBLE' in table
19
23
  * @param {number} length between 1-255
20
24
  * @param {number} decimal 0.000...n
25
+ * @return {this} this
21
26
  */
22
27
  double(length?: number, decimal?: number): this;
23
28
  /**
24
- * Assign type
29
+ * Assign type 'FLOAT' in table
25
30
  * @param {number} length between 1-255
26
31
  * @param {number} decimal 0.000...n
32
+ * @return {this} this
27
33
  */
28
34
  float(length?: number, decimal?: number): this;
29
35
  /**
30
- * Assign type
31
- * @param {number} length string between 1-255
36
+ * Assign type 'VARCHAR' in table
37
+ * @param {number} length [length = 100] length of string
38
+ * @return {this} this
32
39
  */
33
- varchar(n?: number): this;
40
+ varchar(length?: number): this;
34
41
  /**
35
- * Assign type
36
- * @param {number} length string between 1-255
42
+ * Assign type 'CHAR' in table
43
+ * @param {number} length [length = 1] length of string
44
+ * @return {this} this
45
+ */
46
+ char(length?: number): this;
47
+ /**
48
+ * Assign type 'LONGTEXT' in table
49
+ * @return {this} this
37
50
  */
38
- char(n?: number): this;
39
51
  longText(): this;
52
+ /**
53
+ * Assign type 'MEDIUMTEXT' in table
54
+ * @param {number} length [length = 1] length of string
55
+ * @return {this} this
56
+ */
40
57
  mediumText(): this;
58
+ /**
59
+ * Assign type 'TINYTEXT' in table
60
+ * @param {number} length [length = 1] length of string
61
+ * @return {this} this
62
+ */
41
63
  tinyText(): this;
64
+ /**
65
+ * Assign type 'TEXT' in table
66
+ * @param {number} length [length = 1] length of string
67
+ * @return {this} this
68
+ */
42
69
  text(): this;
43
70
  /**
44
- * Assign type
45
- * @param {...string} enum n1, n2, n3, ...n
71
+ * Assign type 'ENUM'
72
+ * @param {...string} enums n1, n2, n3, ...n
73
+ * @return {this} this
46
74
  */
47
75
  enum(...enums: Array<string>): this;
76
+ /**
77
+ * Assign type 'DATE' in table
78
+ * @return {this} this
79
+ */
48
80
  date(): this;
81
+ /**
82
+ * Assign type 'DATETIME' in table
83
+ * @return {this} this
84
+ */
49
85
  dateTime(): this;
86
+ /**
87
+ * Assign type 'TIMESTAMP' in table
88
+ * @return {this} this
89
+ */
50
90
  timestamp(): this;
91
+ /**
92
+ * Assign type 'UNSIGNED' in table
93
+ * @return {this} this
94
+ */
51
95
  unsigned(): this;
96
+ /**
97
+ * Assign type 'UNIQUE' in table
98
+ * @return {this} this
99
+ */
52
100
  unique(): this;
101
+ /**
102
+ * Assign type 'NULL' in table
103
+ * @return {this} this
104
+ */
53
105
  null(): this;
106
+ /**
107
+ * Assign type 'NOT NULL' in table
108
+ * @return {this} this
109
+ */
54
110
  notNull(): this;
111
+ /**
112
+ * Assign type 'PRIMARY KEY' in table
113
+ * @return {this} this
114
+ */
55
115
  primary(): this;
56
116
  /**
57
- * Assign attrbuites
58
- * @param {string | number} default value
117
+ * Assign attrbuites 'default' in table
118
+ * @param {string | number} n default value
119
+ * @return {this} this
59
120
  */
60
121
  default(n: string | number): this;
61
- defaultTimestamp(): this;
122
+ /**
123
+ * Assign attrbuites 'default currentTimestamp' in table
124
+ * @return {this} this
125
+ */
126
+ currentTimestamp(): this;
127
+ /**
128
+ * Assign attrbuites 'autoIncrement' in table
129
+ * @return {this} this
130
+ */
62
131
  autoIncrement(): this;
132
+ private _addAssignType;
133
+ private _addAssignAttrbuite;
63
134
  }
64
135
  export { Blueprint };
65
136
  export default Blueprint;