tspace-mysql 1.0.1 → 1.0.2
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/cli/index.d.ts +2 -0
- package/dist/cli/migrate/make.d.ts +2 -0
- package/dist/cli/models/make.d.ts +2 -0
- package/dist/cli/models/model.d.ts +2 -0
- package/dist/cli/tables/make.d.ts +2 -0
- package/dist/cli/tables/table.d.ts +2 -0
- package/dist/lib/config/env.d.ts +8 -0
- package/dist/lib/connections/index.d.ts +2 -0
- package/dist/lib/connections/options.d.ts +4 -0
- package/dist/lib/index.d.ts +8 -0
- package/dist/lib/tspace/AbstractDB.d.ts +7 -0
- package/dist/lib/tspace/AbstractDatabase.d.ts +102 -0
- package/dist/lib/tspace/AbstractModel.d.ts +20 -0
- package/dist/lib/tspace/DB.d.ts +15 -0
- package/dist/lib/tspace/Database.d.ts +151 -0
- package/dist/lib/tspace/Interface.d.ts +25 -0
- package/dist/lib/tspace/Logger.d.ts +1 -0
- package/dist/lib/tspace/Model.d.ts +231 -0
- package/dist/lib/tspace/ProxyHandler.d.ts +5 -0
- package/dist/lib/tspace/Schema.d.ts +44 -0
- package/dist/lib/tspace/index.d.ts +14 -0
- package/dist/lib/utils/constant.d.ts +4 -0
- package/dist/lib/utils/index.d.ts +17 -0
- package/package.json +1 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
declare abstract class AbstractDatabase {
|
|
2
|
+
protected _setters: string[];
|
|
3
|
+
protected $utils: Function;
|
|
4
|
+
protected $db: {
|
|
5
|
+
get: Function;
|
|
6
|
+
set: Function;
|
|
7
|
+
};
|
|
8
|
+
protected $logger: {
|
|
9
|
+
get: Function;
|
|
10
|
+
set: (arg: string) => void;
|
|
11
|
+
check: (arg: string) => boolean;
|
|
12
|
+
};
|
|
13
|
+
protected $attributes: {};
|
|
14
|
+
abstract debug(): void;
|
|
15
|
+
abstract dump(): void;
|
|
16
|
+
abstract dd(): void;
|
|
17
|
+
abstract select(...params: string[]): void;
|
|
18
|
+
abstract distinct(...params: string[]): void;
|
|
19
|
+
abstract whereNull(column: string): void;
|
|
20
|
+
abstract whereNotNull(column: string): void;
|
|
21
|
+
abstract where(column: string, operator: string, value: string): void;
|
|
22
|
+
abstract whereSensitive(column: string, operator: string, value: string): void;
|
|
23
|
+
abstract whereId(id: number): void;
|
|
24
|
+
abstract whereUser(id: number): void;
|
|
25
|
+
abstract whereEmail(value: string): void;
|
|
26
|
+
abstract whereGroupStart(column: string, operator: string, value: string): void;
|
|
27
|
+
abstract whereGroupEnd(column: string, operator: string, value: string): void;
|
|
28
|
+
abstract orWhereGroupStart(column: string, operator: string, value: string): void;
|
|
29
|
+
abstract orWhereGroupEnd(column: string, operator: string, value: string): void;
|
|
30
|
+
abstract orWhere(column: string, operator: string, value: string): void;
|
|
31
|
+
abstract whereIn(column: string, arrayValues: Array<any>): void;
|
|
32
|
+
abstract orWhereIn(column: string, arrayValues: Array<any>): void;
|
|
33
|
+
abstract whereNotIn(column: string, arrayValues: Array<any>): void;
|
|
34
|
+
abstract whereSubQuery(column: string, subQuery: string): void;
|
|
35
|
+
abstract whereNotInSubQuery(column: string, subQuery: string): void;
|
|
36
|
+
abstract orWhereSubQuery(column: string, subQuery: string): void;
|
|
37
|
+
abstract whereBetween(column: string, arrayValue: Array<any>): void;
|
|
38
|
+
abstract having(condition: string): void;
|
|
39
|
+
abstract join(pk: string, fk: string): void;
|
|
40
|
+
abstract rightJoin(pk: string, fk: string): void;
|
|
41
|
+
abstract leftJoin(pk: string, fk: string): void;
|
|
42
|
+
abstract crossJoin(pk: string, fk: string): void;
|
|
43
|
+
abstract orderBy(column: string, order: string): void;
|
|
44
|
+
abstract latest(column: string): void;
|
|
45
|
+
abstract oldest(column: string): void;
|
|
46
|
+
abstract groupBy(column: string): void;
|
|
47
|
+
abstract limit(number: number): void;
|
|
48
|
+
abstract hidden(...columns: string[]): void;
|
|
49
|
+
abstract insert(objects: object): void;
|
|
50
|
+
abstract create(objects: object): void;
|
|
51
|
+
abstract update(objects: object): void;
|
|
52
|
+
abstract insertNotExists(objects: object): void;
|
|
53
|
+
abstract createNotExists(objects: object): void;
|
|
54
|
+
abstract upsert(objects: object): void;
|
|
55
|
+
abstract insertOrUpdate(objects: object): void;
|
|
56
|
+
abstract createOrUpdate(objects: object): void;
|
|
57
|
+
abstract updateOrInsert(objects: object): void;
|
|
58
|
+
abstract updateOrCreate(objects: object): void;
|
|
59
|
+
abstract createMultiple(objects: object): void;
|
|
60
|
+
abstract insertMultiple(objects: object): void;
|
|
61
|
+
abstract except(...params: string[]): void;
|
|
62
|
+
abstract only(...params: string[]): void;
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* @Execute result
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
abstract drop(): Promise<any>;
|
|
69
|
+
abstract truncate(): Promise<any>;
|
|
70
|
+
abstract all(): Promise<any>;
|
|
71
|
+
abstract find(id: number): Promise<any>;
|
|
72
|
+
abstract pagination({ limit, page }: {
|
|
73
|
+
limit: number;
|
|
74
|
+
page: number;
|
|
75
|
+
}): Promise<any>;
|
|
76
|
+
abstract paginate({ limit, page }: {
|
|
77
|
+
limit: number;
|
|
78
|
+
page: number;
|
|
79
|
+
}): Promise<any>;
|
|
80
|
+
abstract first(): Promise<any>;
|
|
81
|
+
abstract get(): Promise<any>;
|
|
82
|
+
abstract findOne(): Promise<any>;
|
|
83
|
+
abstract findMany(): Promise<any>;
|
|
84
|
+
abstract getGroupBy(column: string): Promise<any>;
|
|
85
|
+
abstract findManyGroupBy(column: string): Promise<any>;
|
|
86
|
+
abstract toArray(column: string): Promise<any>;
|
|
87
|
+
abstract toJSON(): Promise<any>;
|
|
88
|
+
abstract toSQL(): string;
|
|
89
|
+
abstract toString(): string;
|
|
90
|
+
abstract count(column: string): Promise<any>;
|
|
91
|
+
abstract sum(column: string): Promise<any>;
|
|
92
|
+
abstract avg(column: string): Promise<any>;
|
|
93
|
+
abstract max(column: string): Promise<any>;
|
|
94
|
+
abstract min(column: string): Promise<any>;
|
|
95
|
+
abstract delete(): Promise<any>;
|
|
96
|
+
abstract exists(): Promise<any>;
|
|
97
|
+
abstract save(): Promise<any>;
|
|
98
|
+
abstract increment(column: string, value: number): Promise<any>;
|
|
99
|
+
abstract decrement(column: string, value: number): Promise<any>;
|
|
100
|
+
abstract faker(round: number): Promise<any>;
|
|
101
|
+
}
|
|
102
|
+
export default AbstractDatabase;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Relation } from './Interface';
|
|
2
|
+
import Database from './Database';
|
|
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, pk, fk, freezeTable, child }: Relation): void;
|
|
16
|
+
abstract hasMany({ name, model, pk, fk, freezeTable, child }: Relation): void;
|
|
17
|
+
abstract belongsTo({ name, model, pk, fk, freezeTable, child }: Relation): void;
|
|
18
|
+
abstract belongsToMany({ name, model, pk, fk, freezeTable, child }: Relation): void;
|
|
19
|
+
}
|
|
20
|
+
export default AbstractModel;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import AbstractDB from './AbstractDB';
|
|
2
|
+
declare class DB extends AbstractDB {
|
|
3
|
+
[x: string]: {};
|
|
4
|
+
constructor();
|
|
5
|
+
table(table: string): this;
|
|
6
|
+
raw(sql: string): Promise<any[]>;
|
|
7
|
+
beginTransaction(): Promise<{
|
|
8
|
+
rollback: () => Promise<boolean>;
|
|
9
|
+
query: never[];
|
|
10
|
+
}>;
|
|
11
|
+
private _initDB;
|
|
12
|
+
private _setupLogger;
|
|
13
|
+
private _setupDB;
|
|
14
|
+
}
|
|
15
|
+
export default DB;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import AbstractDatabase from './AbstractDatabase';
|
|
2
|
+
declare class Database extends AbstractDatabase {
|
|
3
|
+
except(...params: Array<string>): this;
|
|
4
|
+
only(...params: Array<string>): this;
|
|
5
|
+
distinct(column?: string): this;
|
|
6
|
+
select(...params: string[]): this;
|
|
7
|
+
where(column: string, operator?: any, value?: any): this;
|
|
8
|
+
whereId(id: number): this;
|
|
9
|
+
whereEmail(email: string): this;
|
|
10
|
+
whereUser(id: number): this;
|
|
11
|
+
orWhere(column: string, operator?: any, value?: any): this;
|
|
12
|
+
whereIn(column: string, arrayValues: Array<any>): this;
|
|
13
|
+
orWhereIn(column: string, arrayValues: Array<any>): this;
|
|
14
|
+
whereNotIn(column: string, arrayValues: Array<any>): this;
|
|
15
|
+
whereSubQuery(column: string, subQuery: string): this;
|
|
16
|
+
whereNotInSubQuery(column: string, subQuery: string): this;
|
|
17
|
+
orWhereSubQuery(column: string, subQuery: string): this;
|
|
18
|
+
whereBetween(column: string, arrayValue: Array<any>): this;
|
|
19
|
+
whereNull(column: string): this;
|
|
20
|
+
whereNotNull(column: string): this;
|
|
21
|
+
whereSensitive(column: string, operator?: any, value?: any): this;
|
|
22
|
+
whereGroupStart(column: string, operator?: any, value?: any): this;
|
|
23
|
+
orWhereGroupStart(column: string, operator?: any, value?: any): this;
|
|
24
|
+
whereGroupEnd(column: string, operator?: any, value?: any): this;
|
|
25
|
+
orWhereGroupEnd(column: string, operator?: any, value?: any): this;
|
|
26
|
+
having(condition: string): this;
|
|
27
|
+
join(pk: string, fk: string): this;
|
|
28
|
+
rightJoin(pk: string, fk: string): this;
|
|
29
|
+
leftJoin(pk: string, fk: string): this;
|
|
30
|
+
crossJoin(pk: string, fk: string): this;
|
|
31
|
+
orderBy(column: string, order?: any): this;
|
|
32
|
+
latest(column?: string): this;
|
|
33
|
+
oldest(column?: string): this;
|
|
34
|
+
groupBy(column: string): this;
|
|
35
|
+
limit(number?: number): this;
|
|
36
|
+
offset(number?: number): this;
|
|
37
|
+
hidden(...columns: Array<string>): this;
|
|
38
|
+
update(objects: object): this;
|
|
39
|
+
insert(objects: object): this;
|
|
40
|
+
create(objects: object): this;
|
|
41
|
+
createMultiple(data: Array<any>): this;
|
|
42
|
+
insertMultiple(data: Array<any>): this;
|
|
43
|
+
toString(): string;
|
|
44
|
+
toSQL(): string;
|
|
45
|
+
debug(debug?: boolean): this;
|
|
46
|
+
dump(debug?: boolean): this;
|
|
47
|
+
dd(debug?: boolean): this;
|
|
48
|
+
createNotExists(objects: object): this;
|
|
49
|
+
insertNotExists(objects: object): this;
|
|
50
|
+
upsert(objects: object): this;
|
|
51
|
+
updateOrCreate(objects: object): this;
|
|
52
|
+
updateOrInsert(objects: object): this;
|
|
53
|
+
insertOrUpdate(objects: object): this;
|
|
54
|
+
createOrUpdate(objects: object): this;
|
|
55
|
+
rawQuery(sql: string): Promise<any>;
|
|
56
|
+
increment(column?: string, value?: number): Promise<any>;
|
|
57
|
+
decrement(column?: string, value?: number): Promise<any>;
|
|
58
|
+
all(): Promise<any>;
|
|
59
|
+
find(id: number): Promise<any>;
|
|
60
|
+
pagination({ limit, page }?: {
|
|
61
|
+
limit?: number | undefined;
|
|
62
|
+
page?: number | undefined;
|
|
63
|
+
}): Promise<{
|
|
64
|
+
meta: {
|
|
65
|
+
total: number;
|
|
66
|
+
limit: number;
|
|
67
|
+
total_page: number;
|
|
68
|
+
current_page: number;
|
|
69
|
+
last_page: number;
|
|
70
|
+
next_page: number;
|
|
71
|
+
prev_page: number;
|
|
72
|
+
};
|
|
73
|
+
data: never[];
|
|
74
|
+
} | {
|
|
75
|
+
meta: {
|
|
76
|
+
total: number;
|
|
77
|
+
limit: number;
|
|
78
|
+
current_page: number;
|
|
79
|
+
last_page: number;
|
|
80
|
+
next_page: number;
|
|
81
|
+
prev_page: number;
|
|
82
|
+
total_page?: undefined;
|
|
83
|
+
};
|
|
84
|
+
data: any[];
|
|
85
|
+
}>;
|
|
86
|
+
paginate({ limit, page }?: {
|
|
87
|
+
limit?: number | undefined;
|
|
88
|
+
page?: number | undefined;
|
|
89
|
+
}): Promise<{
|
|
90
|
+
meta: {
|
|
91
|
+
total: number;
|
|
92
|
+
limit: number;
|
|
93
|
+
total_page: number;
|
|
94
|
+
current_page: number;
|
|
95
|
+
last_page: number;
|
|
96
|
+
next_page: number;
|
|
97
|
+
prev_page: number;
|
|
98
|
+
};
|
|
99
|
+
data: never[];
|
|
100
|
+
} | {
|
|
101
|
+
meta: {
|
|
102
|
+
total: number;
|
|
103
|
+
limit: number;
|
|
104
|
+
current_page: number;
|
|
105
|
+
last_page: number;
|
|
106
|
+
next_page: number;
|
|
107
|
+
prev_page: number;
|
|
108
|
+
total_page?: undefined;
|
|
109
|
+
};
|
|
110
|
+
data: any[];
|
|
111
|
+
}>;
|
|
112
|
+
first(): Promise<any>;
|
|
113
|
+
findOne(): Promise<any>;
|
|
114
|
+
get(): Promise<any[]>;
|
|
115
|
+
findMany(): Promise<any[]>;
|
|
116
|
+
toJSON(): Promise<string | never[]>;
|
|
117
|
+
toArray(column?: string): Promise<any[]>;
|
|
118
|
+
count(column?: string): Promise<any>;
|
|
119
|
+
exists(): Promise<boolean>;
|
|
120
|
+
avg(column?: string): Promise<any>;
|
|
121
|
+
sum(column?: string): Promise<any>;
|
|
122
|
+
max(column?: string): Promise<any>;
|
|
123
|
+
min(column?: string): Promise<any>;
|
|
124
|
+
delete(): Promise<boolean>;
|
|
125
|
+
getGroupBy(column: string): Promise<any>;
|
|
126
|
+
findManyGroupBy(column: string): Promise<any>;
|
|
127
|
+
save(transaction?: {
|
|
128
|
+
query: {
|
|
129
|
+
table: string;
|
|
130
|
+
id: string;
|
|
131
|
+
}[];
|
|
132
|
+
}): Promise<any>;
|
|
133
|
+
faker(rounds?: number): Promise<any>;
|
|
134
|
+
truncate(): Promise<boolean>;
|
|
135
|
+
drop(): Promise<boolean>;
|
|
136
|
+
private _insertNotExists;
|
|
137
|
+
private _queryStatement;
|
|
138
|
+
private _actionStatement;
|
|
139
|
+
private _create;
|
|
140
|
+
private _createMultiple;
|
|
141
|
+
private _updateOrInsert;
|
|
142
|
+
private _update;
|
|
143
|
+
private _hiddenColumn;
|
|
144
|
+
private _queryUpdate;
|
|
145
|
+
private _queryInsert;
|
|
146
|
+
private _queryInsertMultiple;
|
|
147
|
+
private _valueAndOperator;
|
|
148
|
+
private _valueTrueFalse;
|
|
149
|
+
private _getSQL;
|
|
150
|
+
}
|
|
151
|
+
export default Database;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface Relation {
|
|
2
|
+
name: string;
|
|
3
|
+
model: any;
|
|
4
|
+
as?: string;
|
|
5
|
+
pk?: string | undefined;
|
|
6
|
+
fk?: string | undefined;
|
|
7
|
+
select?: string | undefined;
|
|
8
|
+
hidden?: string | undefined;
|
|
9
|
+
freezeTable?: string | undefined;
|
|
10
|
+
query?: Object | undefined;
|
|
11
|
+
relation?: Object | undefined;
|
|
12
|
+
child?: boolean | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface RelationShip {
|
|
15
|
+
hasOne: string;
|
|
16
|
+
hasMany: string;
|
|
17
|
+
belongsTo: string;
|
|
18
|
+
belongsToMany: string;
|
|
19
|
+
}
|
|
20
|
+
export interface RelationShipChild {
|
|
21
|
+
hasOne: string;
|
|
22
|
+
hasMany: string;
|
|
23
|
+
belongsTo: string;
|
|
24
|
+
}
|
|
25
|
+
export declare type Pattern = 'snake_case' | 'camelCase';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LoggerMethod: (self: any, prop: string) => void;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import AbstractModel from './AbstractModel';
|
|
2
|
+
import { Relation } from './Interface';
|
|
3
|
+
declare class Model extends AbstractModel {
|
|
4
|
+
[x: string]: {};
|
|
5
|
+
constructor();
|
|
6
|
+
useRegistry(): this;
|
|
7
|
+
useUUID(custom?: string): this;
|
|
8
|
+
useDebug(): this;
|
|
9
|
+
usePattern(pattern: string): this;
|
|
10
|
+
useSoftDelete(): this;
|
|
11
|
+
useTimestamp(): this;
|
|
12
|
+
useTable(table: string): this;
|
|
13
|
+
disabledSoftDelete(): this;
|
|
14
|
+
registry(func: any): this;
|
|
15
|
+
withQuery(name: string, cb: Function): this;
|
|
16
|
+
with(...nameRelations: Array<any>): this;
|
|
17
|
+
withExists(...nameRelations: Array<string>): this;
|
|
18
|
+
whereUser(id: number): this;
|
|
19
|
+
hasOne({ name, as, model, pk, fk, freezeTable }: Relation): this;
|
|
20
|
+
hasMany({ name, as, model, pk, fk, freezeTable }: Relation): this;
|
|
21
|
+
belongsTo({ name, as, model, pk, fk, freezeTable }: Relation): this;
|
|
22
|
+
belongsToMany({ name, as, model, pk, fk, freezeTable }: Relation): this;
|
|
23
|
+
trashed(): Promise<any>;
|
|
24
|
+
onlyTrashed(): Promise<any>;
|
|
25
|
+
restore(): Promise<any>;
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @Override Method
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
toString(): string;
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @Override Method
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
toSQL(): string;
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @Override Method
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
toJSON(): Promise<string | never[]>;
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* @Override Method
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
toArray(column?: string): Promise<any[]>;
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @Override Method
|
|
53
|
+
*
|
|
54
|
+
*/
|
|
55
|
+
avg(column?: string): Promise<any>;
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @Override Method
|
|
59
|
+
*
|
|
60
|
+
*/
|
|
61
|
+
sum(column?: string): Promise<any>;
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @Override Method
|
|
65
|
+
*
|
|
66
|
+
*/
|
|
67
|
+
max(column?: string): Promise<any>;
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
* @Override Method
|
|
71
|
+
*
|
|
72
|
+
*/
|
|
73
|
+
min(column?: string): Promise<any>;
|
|
74
|
+
/**
|
|
75
|
+
*
|
|
76
|
+
* @Override Method
|
|
77
|
+
*
|
|
78
|
+
*/
|
|
79
|
+
count(column?: string): Promise<any>;
|
|
80
|
+
/**
|
|
81
|
+
*
|
|
82
|
+
* @Override Method
|
|
83
|
+
*
|
|
84
|
+
*/
|
|
85
|
+
delete(): Promise<boolean>;
|
|
86
|
+
/**
|
|
87
|
+
*
|
|
88
|
+
* @Override Method
|
|
89
|
+
*
|
|
90
|
+
*/
|
|
91
|
+
first(): Promise<any>;
|
|
92
|
+
/**
|
|
93
|
+
*
|
|
94
|
+
* @Override Method
|
|
95
|
+
*
|
|
96
|
+
*/
|
|
97
|
+
all(): Promise<any>;
|
|
98
|
+
/**
|
|
99
|
+
*
|
|
100
|
+
* @Override Method
|
|
101
|
+
*
|
|
102
|
+
*/
|
|
103
|
+
find(id: number): Promise<any>;
|
|
104
|
+
/**
|
|
105
|
+
*
|
|
106
|
+
* @Override Method
|
|
107
|
+
*
|
|
108
|
+
*/
|
|
109
|
+
findOne(): Promise<any>;
|
|
110
|
+
/**
|
|
111
|
+
*
|
|
112
|
+
* @Override Method
|
|
113
|
+
*
|
|
114
|
+
*/
|
|
115
|
+
get(): Promise<any>;
|
|
116
|
+
/**
|
|
117
|
+
*
|
|
118
|
+
* @Override Method
|
|
119
|
+
*
|
|
120
|
+
*/
|
|
121
|
+
findMany(): Promise<any>;
|
|
122
|
+
/**
|
|
123
|
+
*
|
|
124
|
+
* @Override Method
|
|
125
|
+
*
|
|
126
|
+
*/
|
|
127
|
+
pagination({ limit, page }?: {
|
|
128
|
+
limit?: number | undefined;
|
|
129
|
+
page?: number | undefined;
|
|
130
|
+
}): Promise<any>;
|
|
131
|
+
paginate({ limit, page }?: {
|
|
132
|
+
limit?: number | undefined;
|
|
133
|
+
page?: number | undefined;
|
|
134
|
+
}): Promise<any>;
|
|
135
|
+
/**
|
|
136
|
+
*
|
|
137
|
+
* @Override Method
|
|
138
|
+
*
|
|
139
|
+
*/
|
|
140
|
+
getGroupBy(column: string): Promise<any>;
|
|
141
|
+
/**
|
|
142
|
+
*
|
|
143
|
+
* @Override Method
|
|
144
|
+
*
|
|
145
|
+
*/
|
|
146
|
+
update(objects: object): this;
|
|
147
|
+
/**
|
|
148
|
+
*
|
|
149
|
+
* @Override Method
|
|
150
|
+
*
|
|
151
|
+
*/
|
|
152
|
+
insert(objects: object): this;
|
|
153
|
+
/**
|
|
154
|
+
*
|
|
155
|
+
* @Override Method
|
|
156
|
+
*
|
|
157
|
+
*/
|
|
158
|
+
create(objects: object): this;
|
|
159
|
+
/**
|
|
160
|
+
*
|
|
161
|
+
* @Override Method
|
|
162
|
+
*
|
|
163
|
+
*/
|
|
164
|
+
updateOrCreate(objects: object): this;
|
|
165
|
+
updateOrInsert(objects: object): this;
|
|
166
|
+
insertOrUpdate(objects: object): this;
|
|
167
|
+
createOrUpdate(objects: object): this;
|
|
168
|
+
/**
|
|
169
|
+
*
|
|
170
|
+
* @Override Method
|
|
171
|
+
*
|
|
172
|
+
*/
|
|
173
|
+
createMultiple(data: Array<any>): this;
|
|
174
|
+
/**
|
|
175
|
+
*
|
|
176
|
+
* @Override Method
|
|
177
|
+
*
|
|
178
|
+
*/
|
|
179
|
+
insertMultiple(data: Array<any>): this;
|
|
180
|
+
private _queryStatementModel;
|
|
181
|
+
private _actionStatementModel;
|
|
182
|
+
private _isPatternSnakeCase;
|
|
183
|
+
private _classToTableName;
|
|
184
|
+
private _tableName;
|
|
185
|
+
private _valueInRelation;
|
|
186
|
+
private _getSQLModel;
|
|
187
|
+
private _exceptColumns;
|
|
188
|
+
private _showOnly;
|
|
189
|
+
private _exec;
|
|
190
|
+
private _execGroup;
|
|
191
|
+
private _relationFilter;
|
|
192
|
+
private _relation;
|
|
193
|
+
private _belongsToMany;
|
|
194
|
+
private _pagination;
|
|
195
|
+
private _result;
|
|
196
|
+
private _returnEmpty;
|
|
197
|
+
private _returnResult;
|
|
198
|
+
private _hiddenColumnModel;
|
|
199
|
+
private _attach;
|
|
200
|
+
private _detach;
|
|
201
|
+
private _queryUpdateModel;
|
|
202
|
+
private _queryInsertModel;
|
|
203
|
+
private _queryInsertMultipleModel;
|
|
204
|
+
private _registry;
|
|
205
|
+
private _insertNotExistsModel;
|
|
206
|
+
private _createModel;
|
|
207
|
+
private _createMultipleModel;
|
|
208
|
+
private _updateOrInsertModel;
|
|
209
|
+
private _updateModel;
|
|
210
|
+
/**
|
|
211
|
+
*
|
|
212
|
+
* @Override Method
|
|
213
|
+
*
|
|
214
|
+
*/
|
|
215
|
+
save(transaction?: {
|
|
216
|
+
query: {
|
|
217
|
+
table: string;
|
|
218
|
+
id: string;
|
|
219
|
+
}[];
|
|
220
|
+
}): Promise<any>;
|
|
221
|
+
/**
|
|
222
|
+
*
|
|
223
|
+
* @Override Method
|
|
224
|
+
*
|
|
225
|
+
*/
|
|
226
|
+
faker(rounds?: number): Promise<any>;
|
|
227
|
+
private _initModel;
|
|
228
|
+
private _setupLogger;
|
|
229
|
+
private _setupModel;
|
|
230
|
+
}
|
|
231
|
+
export default Model;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import Database from "./Database";
|
|
2
|
+
export declare class Schema extends Database {
|
|
3
|
+
protected timeStamp: Array<string>;
|
|
4
|
+
table: (table: string, schemas: any) => Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export declare class Blueprint {
|
|
7
|
+
protected type: string | undefined;
|
|
8
|
+
protected attrbuites: Array<string>;
|
|
9
|
+
private _addType;
|
|
10
|
+
private _addAttrbuite;
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @Types
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
int(): this;
|
|
17
|
+
tinyInt(n?: number): this;
|
|
18
|
+
bigInt(n?: number): this;
|
|
19
|
+
double(): this;
|
|
20
|
+
float(): this;
|
|
21
|
+
varchar(n?: number): this;
|
|
22
|
+
char(n?: number): this;
|
|
23
|
+
longText(): this;
|
|
24
|
+
mediumText(): this;
|
|
25
|
+
tinyText(): this;
|
|
26
|
+
text(): this;
|
|
27
|
+
enum(...n: Array<string>): this;
|
|
28
|
+
date(): this;
|
|
29
|
+
dateTime(): this;
|
|
30
|
+
timestamp(): this;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @Attrbuites
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
unsigned(): this;
|
|
37
|
+
unique(): this;
|
|
38
|
+
null(): this;
|
|
39
|
+
notNull(): this;
|
|
40
|
+
primary(): this;
|
|
41
|
+
default(n: string): this;
|
|
42
|
+
defaultTimestamp(): this;
|
|
43
|
+
autoIncrement(): this;
|
|
44
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import DB from './DB';
|
|
2
|
+
import Model from './Model';
|
|
3
|
+
import { Schema, Blueprint } from './Schema';
|
|
4
|
+
export { DB };
|
|
5
|
+
export { Model };
|
|
6
|
+
export { Schema };
|
|
7
|
+
export { Blueprint };
|
|
8
|
+
declare const _default: {
|
|
9
|
+
DB: typeof DB;
|
|
10
|
+
Model: typeof Model;
|
|
11
|
+
Schema: typeof Schema;
|
|
12
|
+
Blueprint: typeof Blueprint;
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
consoleDebug: (message?: string | undefined) => void;
|
|
3
|
+
tableName: (name: string) => string;
|
|
4
|
+
faker: (value: string) => string | number | boolean;
|
|
5
|
+
connection: () => Promise<any>;
|
|
6
|
+
columnRelation: (name: string) => string;
|
|
7
|
+
timestamp: () => string;
|
|
8
|
+
date: () => string;
|
|
9
|
+
escape: (str: any) => any;
|
|
10
|
+
escapeSubQuery: (str: any) => any;
|
|
11
|
+
generateUUID: () => string;
|
|
12
|
+
constants: (name?: string | undefined) => any;
|
|
13
|
+
covertBooleanToNumber: (data: any) => any;
|
|
14
|
+
snakeCase: (obj: any) => any;
|
|
15
|
+
camelCase: (obj: any) => any;
|
|
16
|
+
};
|
|
17
|
+
export default _default;
|