-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
388 lines (238 loc) · 10.2 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
import {CreateTable, FilterWithId, FnResult, Query, TargetTable} from './package/type/db/Query';
import {Cnj, COP, Operator, RefState} from './package/enum/helper';
import {NULL, NOT_NULL, AUTO_INCREMENT} from './package/sql/PubStr';
import {JoinObject, JsonChecker, JSONObject, QCheckValueInObject} from './package/typing';
declare module 'opensql' {
export class OpenSql {
constructor(url: string, option?: object)
/**
* Find all or specifce rows
* @param {Query} query
* @return {Promise<any>}
*/
find(query: Query): Promise<any>;
/**
* Find one row
* @param {Query} query
* @return {Promise<any>}
*/
findOne(query: Query): Promise<any>;
/**
* Find one by id
* @param {Number} id
* @param {FilterWithId} filter
* @return {Promise<any>}
*/
findById(id: number, filter: FilterWithId): Promise<any>;
/**
* FindMany method It is the same as the find method, with the difference that you don't need to write limit, you can only enter your desired limitation in the second parameter.
* @param {Query} query
* @param {Number} limit
* @return {Promise<any>}
*/
findMany(query: Query, limit?: number): Promise<any>;
/**
* Update all or specifce rows
* @param {Query} query
* @return {Promise<any>}
*/
update(query: Query): Promise<any>;
/**
* Remove all or specifce rows
* @param {Query} query
* @return {Promise<any>}
*/
remove(query: Query): Promise<any>;
/**
* AddOne row
* @param {Query} query
* @return {Promise<any>}
*/
addOne(query: Query): Promise<any>;
/**
* Add row with find row
* @param {String|TargetTable} targetTableName
* @param {Query} query
* @return {Promise<any>}
*/
addWithFind(targetTableName: string | TargetTable, query: Query): Promise<any>;
/**
* Add many rows
* @param {Query} query
* @return {Promise<any>}
*/
addMany(query: Query): Promise<any>;
/**
* Create database
* @param {String} name
* @param {String} set
* @param {String} collate
* @return {Promise<any>}
*/
createDatabase(name: string, set?: string, collate?: string): Promise<any>;
/**
* Drop database
* @param {String} name
* @return {Promise<any>}
*/
dropDatabase(name: string): Promise<any>;
/**
* Create table
* @param {CreateTable} ct
* @return {Promise<any>}
*/
createTable(ct: CreateTable): Promise<any>;
/**
* Drop table
* @param {String|String[]} tableName
* @return {Promise<any>}
*/
dropTable(tableName: string | string[]): Promise<any>;
/**
* Truncate table
* @param {String} tableName
* @return {Promise<any>}
*/
truncateTable(tableName: string): Promise<any>;
/**
* Custom query
* @param {String} sql
* @param {any} injection
* @return {Promise<any>}
*/
query(sql: string, injection?: any): Promise<any>;
/**
* Disconnect
* @return {void}
*/
disconnect(): void;
}
const Cnj: Cnj
const COP: COP
const Operator: Operator
const RefState: RefState
const NULL: string;
const NOT_NULL: string;
const AUTO_INCREMENT: string;
interface DataType {
VARCHAR(data?: number | any[]): string;
INT(data?: number | any[]): string;
CHAR(data?: number | any[]): string;
DATE(data?: any[]): string;
DATETIME(data?: any[]): string;
ENUM(data?: number | any[]): string;
BOOLEAN(data?: number | any[]): string;
POINT(data?: number | any[]): string;
TINYINT(data?: number | any[]): string;
SMALLINT(data?: number | any[]): string;
MEDIUMINT(data?: number | any[]): string;
BIGINT(data?: number | any[]): string;
DECIMAL(data?: number | any[]): string;
FLOAT(data?: number | any[]): string;
DOUBLE(data?: number | any[]): string;
REAL(data?: number | any[]): string;
BIT(data?: number | any[]): string;
SERIAL(data?: number | any[]): string;
TIMESTAMP(data?: number | any[]): string;
TIME(data?: number | any[]): string;
YEAR(data?: number | any[]): string;
TINYTEXT(data?: number | any[]): string;
TEXT(data?: number | any[]): string;
MEDIUMTEXT(data?: number | any[]): string;
LONGTEXT(data?: number | any[]): string;
BINARY(data?: number | any[]): string;
VARBINARY(data?: number | any[]): string;
TINYBLOB(data?: number | any[]): string;
BLOB(data?: number | any[]): string;
MEDIUMBLOB(data?: number | any[]): string;
LONGBLOB(data?: number | any[]): string;
SET(data?: number | any[]): string;
MONEY(data: number | any[]): string;
SMALLMONEY(data: number | any[]): string;
SMALLDATETIME(data: number | any[]): string;
DATETIME2(data: number | any[]): string;
VARCHARMAX(data: number | any[]): string;
NVARCHAR(data: number | any[]): string;
NVARCHARMAX(data: number | any[]): string;
NCHAR(data: number | any[]): string;
NTEXT(data: number | any[]): string;
VARBINARYMAX(data: number | any[]): string;
XML(data: number | any[]): string;
SMALLSERIAL(data: number | any[]): string;
CHARACTERVARYING(data: number | any[]): string;
BYTEA(data: number | any[]): string;
CIDR(data: number | any[]): string;
INET(data: number | any[]): string;
MACADDR(data: number | any[]): string;
MACADDR8(data: number | any[]): string;
TSVECTOR(data: number | any[]): string;
TSQUERY(data: number | any[]): string;
JSON(data: number | any[]): string;
UUID(data: number | any[]): string;
POLYGON(data: number | any[]): string;
GEOMETRY(data: number | any[]): string;
LINESTRING(data: number | any[]): string;
}
export function AS(data: string, columnName: string): string;
export function IN(arr: (string | number)[], conjunction?: Cnj): FnResult;
export function NOW(): string;
export function DAY(date: string): string;
export function MAX(column: string): string;
export function MIN(column: string): string;
export function SUM(column: string): string;
export function AVG(column: string): string;
export function LEFT(query: Query): FnResult;
export function UUID(): string;
export function BLOB(buf: Buffer): string;
export function JSON(data: number[] | string[] | JSONObject | JSONObject[]): string;
export function LIKE(str: string, conjunction?: Cnj): FnResult;
export function CAST(data: number | string, type: string): string;
export function FULL(query: Query): FnResult;
export function RIGHT(query: Query): FnResult;
export function COUNT(column?: string | string[]): string;
export function UPPER(string: string): string;
export function LOWER(string: string): string;
export function INNER(query: Query): FnResult;
export function ASCII(char: string | number): string;
export function POINT(x: number, y: number): string;
export function UNION(query: Query): FnResult;
export function qCheck(value: QCheckValueInObject | string | number, comparisonOperator?: COP, conjunction?: Cnj): FnResult;
export function BINARY(data: number): string;
export function ATTACH(arr: JSONObject | string[], conjunction?: Cnj): FnResult;
export function NOT_IN(arr: (string | number)[], conjunction?: Cnj): FnResult;
export function SOURCE(name: string, typeName?: string): string;
export function POLYGON(str: string): string;
export function DAYNAME(date: string): string;
export function COMMENT(description: string): string;
export function REVERSE(string: string): string;
export function DEFAULT(value: string | number | boolean): string;
export function BETWEEN(first: string | number, second: string | number, conjunction?: Cnj): FnResult;
export function UTC_DATE(): string;
export function NOT_LIKE(str: string, conjunction?: Cnj): FnResult;
export function UTC_TIME(): string;
export function XML(data: string): string;
export function UNQUOTE(extract: string): string;
export function CONTAINS(target: JSONObject | string, candidate: JSONObject | string, path?: string): string;
export function EXTRACT(data: JSONObject | number[] | string, ...path: string[]): string;
export function jsonChecker(key: string, has: string): JsonChecker;
export function TINYBLOB(buf: Buffer): string;
export function LONGBLOB(buf: Buffer): string;
export function CONCAT_WS(str: string, arr: string[], column?: string): string;
export function Condition(leftStatement: string, rightStatement: string | number, comparisonOperator?: COP, conjunction?: Cnj): FnResult;
export function UNION_ALL(query: Query): FnResult;
export function VARBINARY(data: number): string;
export function DAYOFWEEK(date: string): string;
export function DAYOFYEAR(date: string): string;
export function QueryPoint(field: string): string;
export function DAYOFMONTH(date: string): string;
export function LINESTRING(str: string | string[]): string;
export function UUID_SHORT(): string;
export function MEDIUMBLOB(buf: Buffer): string;
export function CHAR_LENGTH(data: string | number): string;
export function NOT_BETWEEN(first: string | number, second: string | number, conjunction?: Cnj): FnResult;
export function CURRENT_USER(): string;
export function CURRENT_DATE(): string;
export function CURRENT_TIME(): string;
export function UTC_TIMESTAMP(): string;
export function ST_GeomFromText(string: string): string;
}