tspace-mysql 1.5.7 → 1.5.8
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 +141 -2
- package/build/lib/core/Abstracts/AbstractModel.d.ts +4 -2
- package/build/lib/core/Abstracts/AbstractModel.js.map +1 -1
- package/build/lib/core/Blueprint.d.ts +100 -67
- package/build/lib/core/Blueprint.js +306 -243
- package/build/lib/core/Blueprint.js.map +1 -1
- package/build/lib/core/Builder.d.ts +146 -146
- package/build/lib/core/Builder.js +146 -146
- package/build/lib/core/DB.d.ts +43 -43
- package/build/lib/core/DB.js +43 -43
- package/build/lib/core/Model.d.ts +271 -236
- package/build/lib/core/Model.js +369 -299
- package/build/lib/core/Model.js.map +1 -1
- package/build/lib/core/Repository.d.ts +3 -3
- package/build/lib/core/Repository.js.map +1 -1
- package/build/lib/core/UtilityTypes.d.ts +21 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ npm install tspace-mysql -g
|
|
|
63
63
|
- [Observer](#observer)
|
|
64
64
|
- [Logger](#logger)
|
|
65
65
|
- [Hooks](#hooks)
|
|
66
|
-
- [SoftDelete](#
|
|
66
|
+
- [SoftDelete](#softdelete)
|
|
67
67
|
- [Schema](#schema)
|
|
68
68
|
- [Schema Model](#schema-model)
|
|
69
69
|
- [Validation](#validation)
|
|
@@ -75,6 +75,7 @@ npm install tspace-mysql -g
|
|
|
75
75
|
- [Many To Many](#many-to-many)
|
|
76
76
|
- [Deeply Nested Relations](#deeply-nested-relations)
|
|
77
77
|
- [Relation Exists](#relation-exists)
|
|
78
|
+
- [Relation Trashed](#relation-trashed)
|
|
78
79
|
- [Built in Relation Functions](#built-in-relation-functions)
|
|
79
80
|
- [Decorator](#decorator)
|
|
80
81
|
- [Type Safety](#type-safety)
|
|
@@ -1414,6 +1415,10 @@ class User extends Model {
|
|
|
1414
1415
|
const user = await new User().where('user_id',1).findOne()
|
|
1415
1416
|
// SELECT * FROM `users` WHERE `users`.`userId` = '1' and `users`.`deletedAtCustom` IS NULL LIMIT 1;
|
|
1416
1417
|
|
|
1418
|
+
// find in trashed
|
|
1419
|
+
const user = await new User().trashed().findMany()
|
|
1420
|
+
// SELECT * FROM `users` WHERE `users`.`userId` = '1' and `users`.`deletedAtCustom` IS NOT NULL;
|
|
1421
|
+
|
|
1417
1422
|
```
|
|
1418
1423
|
|
|
1419
1424
|
### Relationships
|
|
@@ -1700,6 +1705,9 @@ class Post extends Model {
|
|
|
1700
1705
|
}
|
|
1701
1706
|
// normal relations
|
|
1702
1707
|
await new User().relations('posts').findMany()
|
|
1708
|
+
// SELECT * FROM `users` WHERE `users`.`deleted_at`;
|
|
1709
|
+
// SELECT * FROM `posts` WHERE `posts`.`userId` IN (...) AND `posts`.`deleted_at` IS NULL;
|
|
1710
|
+
|
|
1703
1711
|
/*
|
|
1704
1712
|
* @returns [
|
|
1705
1713
|
* {
|
|
@@ -1730,6 +1738,11 @@ await new User().relations('posts').findMany()
|
|
|
1730
1738
|
*/
|
|
1731
1739
|
|
|
1732
1740
|
await new User().relationsExists('posts').findMany()
|
|
1741
|
+
// SELECT * FROM `users` WHERE `users`.`deleted_at` IS NULL
|
|
1742
|
+
// AND EXISTS (SELECT 1 FROM `posts` WHERE `users`.`id` = `posts`.`user_id` AND `posts`.`deletedA_at` IS NULL );
|
|
1743
|
+
|
|
1744
|
+
// SELECT * FROM `posts` WHERE `posts`.`user_id` IN (...) AND `posts`.`deleted_at` IS NULL;
|
|
1745
|
+
|
|
1733
1746
|
/*
|
|
1734
1747
|
* @returns [
|
|
1735
1748
|
* {
|
|
@@ -1748,6 +1761,130 @@ await new User().relationsExists('posts').findMany()
|
|
|
1748
1761
|
* because posts id 1 and id 3 has been removed from database (using soft delete)
|
|
1749
1762
|
*/
|
|
1750
1763
|
|
|
1764
|
+
```
|
|
1765
|
+
|
|
1766
|
+
#### Relation Trashed
|
|
1767
|
+
Relationships can return results only if they are deleted in table, considering soft deletes.
|
|
1768
|
+
Let's illustrate this with an example:
|
|
1769
|
+
```js
|
|
1770
|
+
|
|
1771
|
+
+-------------+--------------+----------------------------+--------------------+
|
|
1772
|
+
| table users | |
|
|
1773
|
+
+-------------+--------------+----------------------------+--------------------+
|
|
1774
|
+
| id | username | email | deleted_at |
|
|
1775
|
+
|-------------|--------------|----------------------------|--------------------|
|
|
1776
|
+
| 1 | tspace1 | tspace1@gmail.com | |
|
|
1777
|
+
| 2 | tspace2 | tspace2@gmail.com | |
|
|
1778
|
+
| 3 | tspace3 | tspace3@gmail.com |2020-07-15 00:00:00 |
|
|
1779
|
+
+-------------+--------------+----------------------------+--------------------+
|
|
1780
|
+
|
|
1781
|
+
+-------------+--------------+----------------------------+--------------------+
|
|
1782
|
+
| table posts | |
|
|
1783
|
+
+-------------+--------------+----------------------------+--------------------+
|
|
1784
|
+
| id | user_id | title | deleted_at |
|
|
1785
|
+
|-------------|--------------|----------------------------|--------------------|
|
|
1786
|
+
| 1 | 1 | posts 1 |2020-07-15 00:00:00 |
|
|
1787
|
+
| 2 | 2 | posts 2 | |
|
|
1788
|
+
| 3 | 3 | posts 3 |2020-07-15 00:00:00 |
|
|
1789
|
+
+-------------+--------------+----------------------------+--------------------+
|
|
1790
|
+
|
|
1791
|
+
import { Model } from 'tspace-mysql'
|
|
1792
|
+
|
|
1793
|
+
class User extends Model {
|
|
1794
|
+
constructor(){
|
|
1795
|
+
super()
|
|
1796
|
+
this.hasMany({ name : 'posts' , model : Post })
|
|
1797
|
+
this.useSoftDelete()
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
+--------------------------------------------------------------------------+
|
|
1802
|
+
|
|
1803
|
+
class Post extends Model {
|
|
1804
|
+
constructor(){
|
|
1805
|
+
super()
|
|
1806
|
+
this.hasMany({ name : 'comments' , model : Comment })
|
|
1807
|
+
this.belongsTo({ name : 'user' , model : User })
|
|
1808
|
+
this.useSoftDelete()
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
// normal relations
|
|
1813
|
+
await new User().relations('posts').findMany()
|
|
1814
|
+
// SELECT * FROM `users` WHERE `users`.`deleted_at` IS NULL;
|
|
1815
|
+
// SELECT * FROM `posts` WHERE `posts`.`user_id` IN (...) AND `posts`.`deleted_at` IS NULL;
|
|
1816
|
+
|
|
1817
|
+
/*
|
|
1818
|
+
* @returns [
|
|
1819
|
+
* {
|
|
1820
|
+
* id : 1,
|
|
1821
|
+
* username: "tspace1",
|
|
1822
|
+
* email : "tspace1@gmail.com",
|
|
1823
|
+
* posts : []
|
|
1824
|
+
* }
|
|
1825
|
+
* {
|
|
1826
|
+
* id : 2,
|
|
1827
|
+
* username: "tspace2",
|
|
1828
|
+
* email : "tspace2@gmail.com",
|
|
1829
|
+
* posts : [
|
|
1830
|
+
* {
|
|
1831
|
+
* id : 2,
|
|
1832
|
+
* user_id : 2,
|
|
1833
|
+
* title : "posts 2"
|
|
1834
|
+
* }
|
|
1835
|
+
* ]
|
|
1836
|
+
* }
|
|
1837
|
+
* ]
|
|
1838
|
+
*/
|
|
1839
|
+
|
|
1840
|
+
// relationsTrashed
|
|
1841
|
+
await new User().relationsTrashed('posts').findMany()
|
|
1842
|
+
// SELECT * FROM `users` WHERE `users`.`deleted_at` IS NULL;
|
|
1843
|
+
// SELECT * FROM `posts` WHERE `posts`.`user_id` IN (...) AND `posts`.`deleted_at` IS NOT NULL;
|
|
1844
|
+
|
|
1845
|
+
/*
|
|
1846
|
+
* @returns [
|
|
1847
|
+
* {
|
|
1848
|
+
* id : 1,
|
|
1849
|
+
* username: "tspace1",
|
|
1850
|
+
* email : "tspace1@gmail.com",
|
|
1851
|
+
* posts : [
|
|
1852
|
+
* {
|
|
1853
|
+
* id : 1,
|
|
1854
|
+
* user_id : 1,
|
|
1855
|
+
* title : "posts 1"
|
|
1856
|
+
* }
|
|
1857
|
+
* ]
|
|
1858
|
+
* }
|
|
1859
|
+
* {
|
|
1860
|
+
* id : 2,
|
|
1861
|
+
* username: "tspace2",
|
|
1862
|
+
* email : "tspace2@gmail.com",
|
|
1863
|
+
* posts : []
|
|
1864
|
+
* }
|
|
1865
|
+
* ]
|
|
1866
|
+
*/
|
|
1867
|
+
|
|
1868
|
+
// relationsTrashed + trashed
|
|
1869
|
+
await new User().relationsTrashed('posts').trashed().findMany()
|
|
1870
|
+
// SELECT * FROM `users` WHERE `users`.`deleted_at` IS NOT NULL;
|
|
1871
|
+
// SELECT * FROM `posts` WHERE `posts`.`user_id` IN (...) AND `posts`.`deleted_at` IS NOT NULL;
|
|
1872
|
+
/*
|
|
1873
|
+
* @returns [
|
|
1874
|
+
* {
|
|
1875
|
+
* id : 3,
|
|
1876
|
+
* username: "tspace3",
|
|
1877
|
+
* email : "tspace3@gmail.com",
|
|
1878
|
+
* posts : [
|
|
1879
|
+
* {
|
|
1880
|
+
* id : 3,
|
|
1881
|
+
* user_id : 3,
|
|
1882
|
+
* title : "posts 3"
|
|
1883
|
+
* }
|
|
1884
|
+
* ]
|
|
1885
|
+
* }
|
|
1886
|
+
* ]
|
|
1887
|
+
*/
|
|
1751
1888
|
|
|
1752
1889
|
```
|
|
1753
1890
|
|
|
@@ -2452,7 +2589,8 @@ const users = await new User()
|
|
|
2452
2589
|
|
|
2453
2590
|
## Repository
|
|
2454
2591
|
```js
|
|
2455
|
-
Repository is a mechanism that encapsulates all database operations related to a specific model.
|
|
2592
|
+
Repository is a mechanism that encapsulates all database operations related to a specific model.
|
|
2593
|
+
It provides methods for querying, inserting, updating, and deleting records in the database associated with the model.
|
|
2456
2594
|
|
|
2457
2595
|
** The Repository check always type safety if model is used the type of schema
|
|
2458
2596
|
|
|
@@ -2656,6 +2794,7 @@ import { Schema , Blueprint , DB } from 'tspace-mysql'
|
|
|
2656
2794
|
(async () => {
|
|
2657
2795
|
await new Schema().table('users', {
|
|
2658
2796
|
id : new Blueprint().int().notNull().primary().autoIncrement(),
|
|
2797
|
+
// or id : new Blueprint().serial().primary(),
|
|
2659
2798
|
uuid : new Blueprint().varchar(120).null()
|
|
2660
2799
|
name : new Blueprint().varchar(120).default('name'),
|
|
2661
2800
|
email : new Blueprint().varchar(255).unique().notNull(),
|
|
@@ -58,17 +58,19 @@ declare abstract class AbstractModel<T, R> extends Builder {
|
|
|
58
58
|
abstract registry(func: Record<string, Function>): this;
|
|
59
59
|
abstract onlyTrashed(): this;
|
|
60
60
|
abstract trashed(): this;
|
|
61
|
-
abstract restore(): Promise<
|
|
61
|
+
abstract restore(): Promise<T[]>;
|
|
62
62
|
abstract with<K extends R extends object ? keyof R : string>(...nameRelations: K[]): this;
|
|
63
63
|
abstract withQuery<K extends R extends object ? keyof R : string, TModel extends Model>(nameRelations: K, callback: (query: TModel) => TModel): this;
|
|
64
64
|
abstract withExists<K extends R extends object ? keyof R : string>(...nameRelations: K[]): this;
|
|
65
65
|
abstract withTrashed<K extends R extends object ? keyof R : string>(...nameRelations: K[]): this;
|
|
66
66
|
abstract withAll<K extends R extends object ? keyof R : string>(...nameRelations: K[]): this;
|
|
67
|
+
abstract withCount<K extends R extends object ? keyof R : string>(...nameRelations: K[]): this;
|
|
67
68
|
abstract has<K extends R extends object ? keyof R : string>(...nameRelations: K[]): this;
|
|
68
69
|
abstract relations<K extends R extends object ? keyof R : string>(...nameRelations: K[]): this;
|
|
69
|
-
abstract
|
|
70
|
+
abstract relationQuery<K extends R extends object ? keyof R : string, TModel extends Model>(nameRelations: K, callback: (query: TModel) => TModel): this;
|
|
70
71
|
abstract relationsExists<K extends R extends object ? keyof R : string>(...nameRelations: K[]): this;
|
|
71
72
|
abstract relationsAll<K extends R extends object ? keyof R : string>(...nameRelations: K[]): this;
|
|
73
|
+
abstract relationsCount<K extends R extends object ? keyof R : string>(...nameRelations: K[]): this;
|
|
72
74
|
abstract relationsTrashed<K extends R extends object ? keyof R : string>(...nameRelations: K[]): this;
|
|
73
75
|
}
|
|
74
76
|
export { AbstractModel };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractModel.js","sourceRoot":"","sources":["../../../../src/lib/core/Abstracts/AbstractModel.ts"],"names":[],"mappings":";;;AAEA,wCAAoC;AAIpC,MAAe,aAAmB,SAAQ,iBAAO;
|
|
1
|
+
{"version":3,"file":"AbstractModel.js","sourceRoot":"","sources":["../../../../src/lib/core/Abstracts/AbstractModel.ts"],"names":[],"mappings":";;;AAEA,wCAAoC;AAIpC,MAAe,aAAmB,SAAQ,iBAAO;CAyEhD;AAEQ,sCAAa;AACtB,kBAAe,aAAa,CAAA"}
|
|
@@ -21,81 +21,103 @@ declare class Blueprint<T = any> {
|
|
|
21
21
|
private _column;
|
|
22
22
|
private _valueType;
|
|
23
23
|
/**
|
|
24
|
-
* Assign type '
|
|
24
|
+
* Assign type 'serial' in table
|
|
25
25
|
* @static
|
|
26
|
-
* @return {
|
|
26
|
+
* @return {Blueprint<T>} Blueprint
|
|
27
|
+
*/
|
|
28
|
+
static serial(_?: number): Blueprint<number>;
|
|
29
|
+
/**
|
|
30
|
+
* Assign type 'serial' in table
|
|
31
|
+
* @return {Blueprint<T>} Blueprint
|
|
32
|
+
*/
|
|
33
|
+
serial(_?: number): Blueprint<number>;
|
|
34
|
+
/**
|
|
35
|
+
* Assign type 'INT' in table
|
|
36
|
+
* @static
|
|
37
|
+
* @return {Blueprint<T>} Blueprint
|
|
27
38
|
*/
|
|
28
39
|
static int(_?: number): Blueprint<number>;
|
|
29
40
|
/**
|
|
30
|
-
* Assign type '
|
|
31
|
-
* @return {
|
|
41
|
+
* Assign type 'INT' in table
|
|
42
|
+
* @return {Blueprint<T>} Blueprint
|
|
32
43
|
*/
|
|
33
44
|
int(_?: number): Blueprint<number>;
|
|
34
45
|
/**
|
|
35
46
|
* Assign type 'TINYINT' in table
|
|
36
47
|
* @static
|
|
37
48
|
* @param {number} number
|
|
38
|
-
* @return {
|
|
49
|
+
* @return {Blueprint<T>} Blueprint
|
|
39
50
|
*/
|
|
40
|
-
static tinyInt(number?: number): Blueprint<number>;
|
|
51
|
+
static tinyInt(number?: number): Blueprint<number | boolean>;
|
|
41
52
|
/**
|
|
42
53
|
* Assign type 'TINYINT' in table
|
|
43
54
|
* @param {number} number
|
|
44
|
-
* @return {
|
|
55
|
+
* @return {Blueprint<T>} Blueprint
|
|
45
56
|
*/
|
|
46
|
-
tinyInt(number?: number): Blueprint<number>;
|
|
57
|
+
tinyInt(number?: number): Blueprint<number | boolean>;
|
|
47
58
|
/**
|
|
48
59
|
* Assign type 'TINYINT' in table
|
|
49
60
|
* @static
|
|
50
61
|
* @param {number} number
|
|
51
|
-
* @return {
|
|
62
|
+
* @return {Blueprint<T>} Blueprint
|
|
52
63
|
*/
|
|
53
|
-
static tinyint(number?: number): Blueprint<number>;
|
|
64
|
+
static tinyint(number?: number): Blueprint<number | boolean>;
|
|
54
65
|
/**
|
|
55
66
|
* Assign type 'TINYINT' in table
|
|
56
67
|
* @param {number} number
|
|
57
|
-
* @return {
|
|
68
|
+
* @return {Blueprint<T>} Blueprint
|
|
58
69
|
*/
|
|
59
|
-
tinyint(number?: number): Blueprint<number>;
|
|
70
|
+
tinyint(number?: number): Blueprint<number | boolean>;
|
|
60
71
|
/**
|
|
61
72
|
* Assign type 'BIGINT' in table
|
|
62
73
|
* @static
|
|
63
74
|
* @param {number} number [number = 10]
|
|
64
|
-
* @return {
|
|
75
|
+
* @return {Blueprint<T>} Blueprint
|
|
65
76
|
*/
|
|
66
77
|
static bigInt(number?: number): Blueprint<number>;
|
|
67
78
|
/**
|
|
68
79
|
* Assign type 'BIGINT' in table
|
|
69
80
|
* @param {number} number [number = 10]
|
|
70
|
-
* @return {
|
|
81
|
+
* @return {Blueprint<T>} Blueprint
|
|
71
82
|
*/
|
|
72
83
|
bigInt(number?: number): Blueprint<number>;
|
|
73
84
|
/**
|
|
74
85
|
* Assign type 'BIGINT' in table
|
|
75
86
|
* @static
|
|
76
87
|
* @param {number} number [number = 10]
|
|
77
|
-
* @return {
|
|
88
|
+
* @return {Blueprint<T>} Blueprint
|
|
78
89
|
*/
|
|
79
90
|
static bigint(number?: number): Blueprint<number>;
|
|
80
91
|
/**
|
|
81
92
|
* Assign type 'BIGINT' in table
|
|
82
93
|
* @param {number} number [number = 10]
|
|
83
|
-
* @return {
|
|
94
|
+
* @return {Blueprint<T>} Blueprint
|
|
84
95
|
*/
|
|
85
96
|
bigint(number?: number): Blueprint<number>;
|
|
97
|
+
/**
|
|
98
|
+
* Assign type 'BOOLEAN' in table
|
|
99
|
+
* @static
|
|
100
|
+
* @return {Blueprint<T>} Blueprint
|
|
101
|
+
*/
|
|
102
|
+
static boolean(): Blueprint<number | boolean>;
|
|
103
|
+
/**
|
|
104
|
+
* Assign type 'BOOLEAN' in table
|
|
105
|
+
* @return {Blueprint<T>} Blueprint
|
|
106
|
+
*/
|
|
107
|
+
boolean(): Blueprint<number | boolean>;
|
|
86
108
|
/**
|
|
87
109
|
* Assign type 'DOUBLE' in table
|
|
88
110
|
* @static
|
|
89
111
|
* @param {number} length between 1-255
|
|
90
112
|
* @param {number} decimal 0.000...n
|
|
91
|
-
* @return {
|
|
113
|
+
* @return {Blueprint<T>} Blueprint
|
|
92
114
|
*/
|
|
93
115
|
static double(length?: number, decimal?: number): Blueprint<number>;
|
|
94
116
|
/**
|
|
95
117
|
* Assign type 'DOUBLE' in table
|
|
96
118
|
* @param {number} length between 1-255
|
|
97
119
|
* @param {number} decimal 0.000...n
|
|
98
|
-
* @return {
|
|
120
|
+
* @return {Blueprint<T>} Blueprint
|
|
99
121
|
*/
|
|
100
122
|
double(length?: number, decimal?: number): Blueprint<number>;
|
|
101
123
|
/**
|
|
@@ -103,249 +125,260 @@ declare class Blueprint<T = any> {
|
|
|
103
125
|
* @static
|
|
104
126
|
* @param {number} length between 1-255
|
|
105
127
|
* @param {number} decimal 0.000...n
|
|
106
|
-
* @return {
|
|
128
|
+
* @return {Blueprint<T>} Blueprint
|
|
107
129
|
*/
|
|
108
130
|
static float(length?: number, decimal?: number): Blueprint<number>;
|
|
109
131
|
/**
|
|
110
132
|
* Assign type 'FLOAT' in table
|
|
111
133
|
* @param {number} length between 1-255
|
|
112
134
|
* @param {number} decimal 0.000...n
|
|
113
|
-
* @return {
|
|
135
|
+
* @return {Blueprint<T>} Blueprint
|
|
114
136
|
*/
|
|
115
137
|
float(length?: number, decimal?: number): Blueprint<number>;
|
|
116
138
|
/**
|
|
117
139
|
* Assign type 'VARCHAR' in table
|
|
118
140
|
* @static
|
|
119
141
|
* @param {number} length [length = 191] length of string
|
|
120
|
-
* @return {
|
|
142
|
+
* @return {Blueprint<T>} Blueprint
|
|
121
143
|
*/
|
|
122
144
|
static varchar(length?: number): Blueprint<string>;
|
|
123
145
|
/**
|
|
124
146
|
* Assign type 'VARCHAR' in table
|
|
125
147
|
* @param {number} length [length = 191] length of string
|
|
126
|
-
* @return {
|
|
148
|
+
* @return {Blueprint<T>} Blueprint
|
|
127
149
|
*/
|
|
128
150
|
varchar(length?: number): Blueprint<string>;
|
|
129
151
|
/**
|
|
130
152
|
* Assign type 'CHAR' in table
|
|
131
153
|
* @static
|
|
132
154
|
* @param {number} length [length = 1] length of string
|
|
133
|
-
* @return {
|
|
155
|
+
* @return {Blueprint<T>} Blueprint
|
|
134
156
|
*/
|
|
135
157
|
static char(length?: number): Blueprint<string>;
|
|
136
158
|
/**
|
|
137
159
|
* Assign type 'CHAR' in table
|
|
138
160
|
* @param {number} length [length = 1] length of string
|
|
139
|
-
* @return {
|
|
161
|
+
* @return {Blueprint<T>} Blueprint
|
|
140
162
|
*/
|
|
141
163
|
char(length?: number): Blueprint<string>;
|
|
142
164
|
/**
|
|
143
165
|
* Assign type 'LONGTEXT' in table
|
|
144
166
|
* @static
|
|
145
|
-
* @return {
|
|
167
|
+
* @return {Blueprint<T>} Blueprint
|
|
146
168
|
*/
|
|
147
169
|
static longText(): Blueprint<string>;
|
|
148
170
|
/**
|
|
149
171
|
* Assign type 'LONGTEXT' in table
|
|
150
|
-
* @return {
|
|
172
|
+
* @return {Blueprint<T>} Blueprint
|
|
151
173
|
*/
|
|
152
174
|
longText(): Blueprint<string>;
|
|
175
|
+
/**
|
|
176
|
+
* Assign type 'BINARY' in table
|
|
177
|
+
* @static
|
|
178
|
+
* @return {Blueprint<T>} Blueprint
|
|
179
|
+
*/
|
|
180
|
+
static binary(): Blueprint<string>;
|
|
181
|
+
/**
|
|
182
|
+
* Assign type 'BINARY' in table
|
|
183
|
+
* @return {Blueprint<T>} Blueprint
|
|
184
|
+
*/
|
|
185
|
+
binary(): Blueprint<string>;
|
|
153
186
|
/**
|
|
154
187
|
* Assign type 'LONGTEXT' in table
|
|
155
188
|
* @static
|
|
156
|
-
* @return {
|
|
189
|
+
* @return {Blueprint<T>} Blueprint
|
|
157
190
|
*/
|
|
158
191
|
static longtext(): Blueprint<string>;
|
|
159
192
|
/**
|
|
160
193
|
* Assign type 'LONGTEXT' in table
|
|
161
|
-
* @return {
|
|
194
|
+
* @return {Blueprint<T>} Blueprint
|
|
162
195
|
*/
|
|
163
196
|
longtext(): Blueprint<string>;
|
|
164
197
|
/**
|
|
165
198
|
* Assign type 'JSON' in table
|
|
166
199
|
* @static
|
|
167
|
-
* @return {
|
|
200
|
+
* @return {Blueprint<T>} Blueprint
|
|
168
201
|
*/
|
|
169
202
|
static json(): Blueprint<string>;
|
|
170
203
|
/**
|
|
171
204
|
* Assign type 'JSON' in table
|
|
172
|
-
* @return {
|
|
205
|
+
* @return {Blueprint<T>} Blueprint
|
|
173
206
|
*/
|
|
174
207
|
json(): Blueprint<string>;
|
|
175
208
|
/**
|
|
176
209
|
* Assign type 'MEDIUMTEXT' in table
|
|
177
210
|
* @static
|
|
178
|
-
* @return {
|
|
211
|
+
* @return {Blueprint<T>} Blueprint
|
|
179
212
|
*/
|
|
180
213
|
static mediumText(): Blueprint<string>;
|
|
181
214
|
/**
|
|
182
215
|
* Assign type 'MEDIUMTEXT' in table
|
|
183
|
-
* @return {
|
|
216
|
+
* @return {Blueprint<T>} Blueprint
|
|
184
217
|
*/
|
|
185
218
|
mediumText(): Blueprint<string>;
|
|
186
219
|
/**
|
|
187
220
|
* Assign type 'MEDIUMTEXT' in table
|
|
188
221
|
* @static
|
|
189
|
-
* @return {
|
|
222
|
+
* @return {Blueprint<T>} Blueprint
|
|
190
223
|
*/
|
|
191
224
|
static mediumtext(): Blueprint<string>;
|
|
192
225
|
/**
|
|
193
226
|
* Assign type 'MEDIUMTEXT' in table
|
|
194
|
-
* @return {
|
|
227
|
+
* @return {Blueprint<T>} Blueprint
|
|
195
228
|
*/
|
|
196
229
|
mediumtext(): Blueprint<string>;
|
|
197
230
|
/**
|
|
198
231
|
* Assign type 'TINYTEXT' in table
|
|
199
232
|
* @static
|
|
200
|
-
* @return {
|
|
233
|
+
* @return {Blueprint<T>} Blueprint
|
|
201
234
|
*/
|
|
202
235
|
static tinyText(): Blueprint<string>;
|
|
203
236
|
/**
|
|
204
237
|
* Assign type 'TINYTEXT' in table
|
|
205
|
-
* @return {
|
|
238
|
+
* @return {Blueprint<T>} Blueprint
|
|
206
239
|
*/
|
|
207
240
|
tinyText(): Blueprint<string>;
|
|
208
241
|
/**
|
|
209
242
|
* Assign type 'TINYTEXT' in table
|
|
210
243
|
* @static
|
|
211
|
-
* @return {
|
|
244
|
+
* @return {Blueprint<T>} Blueprint
|
|
212
245
|
*/
|
|
213
246
|
static tinytext(): Blueprint<string>;
|
|
214
247
|
/**
|
|
215
248
|
* Assign type 'TINYTEXT' in table
|
|
216
|
-
* @return {
|
|
249
|
+
* @return {Blueprint<T>} Blueprint
|
|
217
250
|
*/
|
|
218
251
|
tinytext(): Blueprint<string>;
|
|
219
252
|
/**
|
|
220
253
|
* Assign type 'TEXT' in table
|
|
221
254
|
* @static
|
|
222
|
-
* @return {
|
|
255
|
+
* @return {Blueprint<T>} Blueprint
|
|
223
256
|
*/
|
|
224
257
|
static text(): Blueprint<string>;
|
|
225
258
|
/**
|
|
226
259
|
* Assign type 'TEXT' in table
|
|
227
|
-
* @return {
|
|
260
|
+
* @return {Blueprint<T>} Blueprint
|
|
228
261
|
*/
|
|
229
262
|
text(): Blueprint<string>;
|
|
230
263
|
/**
|
|
231
264
|
* Assign type 'ENUM'
|
|
232
265
|
* @static
|
|
233
266
|
* @param {...string} enums n1, n2, n3, ...n
|
|
234
|
-
* @return {
|
|
267
|
+
* @return {Blueprint<T>} Blueprint
|
|
235
268
|
*/
|
|
236
269
|
static enum(...enums: Array<string>): Blueprint<string>;
|
|
237
270
|
/**
|
|
238
271
|
* Assign type 'ENUM'
|
|
239
272
|
* @param {...string} enums n1, n2, n3, ...n
|
|
240
|
-
* @return {
|
|
273
|
+
* @return {Blueprint<T>} Blueprint
|
|
241
274
|
*/
|
|
242
275
|
enum(...enums: Array<string>): Blueprint<string>;
|
|
243
276
|
/**
|
|
244
277
|
* Assign type 'DATE' in table
|
|
245
278
|
* @static
|
|
246
|
-
* @return {
|
|
279
|
+
* @return {Blueprint<T>} Blueprint
|
|
247
280
|
*/
|
|
248
281
|
static date(): Blueprint<Date | string>;
|
|
249
282
|
/**
|
|
250
283
|
* Assign type 'DATE' in table
|
|
251
|
-
* @return {
|
|
284
|
+
* @return {Blueprint<T>} Blueprint
|
|
252
285
|
*/
|
|
253
286
|
date(): Blueprint<Date | string>;
|
|
254
287
|
/**
|
|
255
288
|
* Assign type 'DATETIME' in table
|
|
256
289
|
* @static
|
|
257
|
-
* @return {
|
|
290
|
+
* @return {Blueprint<T>} Blueprint
|
|
258
291
|
*/
|
|
259
292
|
static dateTime(): Blueprint<Date | string>;
|
|
260
293
|
/**
|
|
261
294
|
* Assign type 'DATETIME' in table
|
|
262
|
-
* @return {
|
|
295
|
+
* @return {Blueprint<T>} Blueprint
|
|
263
296
|
*/
|
|
264
297
|
dateTime(): Blueprint<Date | string>;
|
|
265
298
|
/**
|
|
266
299
|
* Assign type 'DATETIME' in table
|
|
267
300
|
* @static
|
|
268
|
-
* @return {
|
|
301
|
+
* @return {Blueprint<T>} Blueprint
|
|
269
302
|
*/
|
|
270
303
|
static datetime(): Blueprint<Date | string>;
|
|
271
304
|
/**
|
|
272
305
|
* Assign type 'DATETIME' in table
|
|
273
|
-
* @return {
|
|
306
|
+
* @return {Blueprint<T>} Blueprint
|
|
274
307
|
*/
|
|
275
308
|
datetime(): Blueprint<Date | string>;
|
|
276
309
|
/**
|
|
277
310
|
* Assign type 'TIMESTAMP' in table
|
|
278
311
|
* @static
|
|
279
|
-
* @return {
|
|
312
|
+
* @return {Blueprint<T>} Blueprint
|
|
280
313
|
*/
|
|
281
|
-
static timestamp(): Blueprint<Date
|
|
314
|
+
static timestamp(): Blueprint<Date>;
|
|
282
315
|
/**
|
|
283
316
|
* Assign type 'TIMESTAMP' in table
|
|
284
|
-
* @return {
|
|
317
|
+
* @return {Blueprint<T>} Blueprint
|
|
285
318
|
*/
|
|
286
|
-
timestamp(): Blueprint<Date
|
|
319
|
+
timestamp(): Blueprint<Date>;
|
|
287
320
|
/**
|
|
288
321
|
* Assign attributes 'UNSIGNED' in table
|
|
289
|
-
* @return {
|
|
322
|
+
* @return {Blueprint<T>} Blueprint
|
|
290
323
|
*/
|
|
291
324
|
unsigned(): Blueprint<T>;
|
|
292
325
|
/**
|
|
293
326
|
* Assign attributes 'UNIQUE' in table
|
|
294
|
-
* @return {
|
|
327
|
+
* @return {Blueprint<T>} Blueprint
|
|
295
328
|
*/
|
|
296
329
|
unique(): Blueprint<T>;
|
|
297
330
|
/**
|
|
298
331
|
* Assign attributes 'NULL' in table
|
|
299
|
-
* @return {
|
|
332
|
+
* @return {Blueprint<T>} Blueprint
|
|
300
333
|
*/
|
|
301
334
|
null(): Blueprint<T | null>;
|
|
302
335
|
/**
|
|
303
336
|
* Assign attributes 'NOT NULL' in table
|
|
304
|
-
* @return {
|
|
337
|
+
* @return {Blueprint<T>} Blueprint
|
|
305
338
|
*/
|
|
306
339
|
notNull(): Blueprint<T>;
|
|
307
340
|
/**
|
|
308
341
|
* Assign attributes 'NOT NULL' in table
|
|
309
|
-
* @return {
|
|
342
|
+
* @return {Blueprint<T>} Blueprint
|
|
310
343
|
*/
|
|
311
344
|
notnull(): Blueprint<T>;
|
|
312
345
|
/**
|
|
313
346
|
* Assign attributes 'PRIMARY KEY' in table
|
|
314
|
-
* @return {
|
|
347
|
+
* @return {Blueprint<T>} Blueprint
|
|
315
348
|
*/
|
|
316
349
|
primary(): Blueprint<T>;
|
|
317
350
|
/**
|
|
318
351
|
* Assign attributes 'default' in table
|
|
319
352
|
* @param {string | number} value default value
|
|
320
|
-
* @return {
|
|
353
|
+
* @return {Blueprint<T>} Blueprint
|
|
321
354
|
*/
|
|
322
355
|
default(value: string | number): Blueprint<T>;
|
|
323
356
|
/**
|
|
324
357
|
* Assign attributes 'defaultValue' in table
|
|
325
358
|
* @param {string | number} value default value
|
|
326
|
-
* @return {
|
|
359
|
+
* @return {Blueprint<T>} Blueprint
|
|
327
360
|
*/
|
|
328
361
|
defaultValue(value: string | number): Blueprint<T>;
|
|
329
362
|
/**
|
|
330
363
|
* Assign attributes 'default currentTimestamp' in table
|
|
331
|
-
* @return {
|
|
364
|
+
* @return {Blueprint<T>} Blueprint
|
|
332
365
|
*/
|
|
333
366
|
currentTimestamp(): Blueprint<T>;
|
|
334
367
|
/**
|
|
335
368
|
* Assign attributes 'default currentTimestamp' in table
|
|
336
|
-
* @return {
|
|
369
|
+
* @return {Blueprint<T>} Blueprint
|
|
337
370
|
*/
|
|
338
371
|
currenttimestamp(): Blueprint<T>;
|
|
339
372
|
/**
|
|
340
373
|
* Assign attributes 'autoIncrement' in table
|
|
341
|
-
* @return {
|
|
374
|
+
* @return {Blueprint<T>} Blueprint
|
|
342
375
|
*/
|
|
343
|
-
autoIncrement(): Blueprint<T
|
|
376
|
+
autoIncrement(): Blueprint<T>;
|
|
344
377
|
/**
|
|
345
378
|
* Assign attributes 'autoIncrement' in table
|
|
346
|
-
* @return {
|
|
379
|
+
* @return {Blueprint<T>} Blueprint
|
|
347
380
|
*/
|
|
348
|
-
autoincrement(): Blueprint<T
|
|
381
|
+
autoincrement(): Blueprint<T>;
|
|
349
382
|
/**
|
|
350
383
|
* Assign attributes 'foreign' in table
|
|
351
384
|
* Reference bettwen Column Main to Column Child
|
|
@@ -354,7 +387,7 @@ declare class Blueprint<T = any> {
|
|
|
354
387
|
* @property {Model | string} property.on
|
|
355
388
|
* @property {string?} property.onDelete
|
|
356
389
|
* @property {string?} property.onUpdate
|
|
357
|
-
* @return {
|
|
390
|
+
* @return {Blueprint<T>} Blueprint
|
|
358
391
|
*/
|
|
359
392
|
foreign({ references, on, onDelete, onUpdate }: {
|
|
360
393
|
references?: string;
|