mysql2-core 0.2.4 → 0.3.1
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/lib/build.js +1 -1
- package/lib/index.js +656 -125
- package/package.json +1 -1
- package/src/build.ts +2 -2
- package/src/index.ts +490 -71
- package/src/metadata.ts +10 -46
package/src/metadata.ts
CHANGED
|
@@ -6,25 +6,22 @@ export interface Statement {
|
|
|
6
6
|
params?: any[]
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export interface
|
|
9
|
+
export interface Executor {
|
|
10
10
|
driver: string
|
|
11
11
|
param(i: number): string
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
execute(sql: string, args?: any[], ctx?: any): Promise<number>
|
|
13
|
+
executeBatch(statements: Statement[], firstSuccess?: boolean, ctx?: any): Promise<number>
|
|
14
14
|
query<T>(sql: string, args?: any[], m?: StringMap, bools?: Attribute[], ctx?: any): Promise<T[]>
|
|
15
15
|
queryOne<T>(sql: string, args?: any[], m?: StringMap, bools?: Attribute[], ctx?: any): Promise<T | null>
|
|
16
|
-
|
|
16
|
+
executeScalar<T>(sql: string, args?: any[], ctx?: any): Promise<T>
|
|
17
17
|
count(sql: string, args?: any[], ctx?: any): Promise<number>
|
|
18
18
|
}
|
|
19
|
-
export interface
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
queryOne<T>(sql: string, args?: any[], m?: StringMap, bools?: Attribute[], ctx?: any): Promise<T | null>
|
|
26
|
-
execScalar<T>(sql: string, args?: any[], ctx?: any): Promise<T>
|
|
27
|
-
count(sql: string, args?: any[], ctx?: any): Promise<number>
|
|
19
|
+
export interface Transaction extends Executor {
|
|
20
|
+
commit(): Promise<void>
|
|
21
|
+
rollback(): Promise<void>
|
|
22
|
+
}
|
|
23
|
+
export interface DB extends Executor {
|
|
24
|
+
beginTransaction(): Promise<Transaction>
|
|
28
25
|
}
|
|
29
26
|
export type DataType =
|
|
30
27
|
| "ObjectId"
|
|
@@ -47,52 +44,19 @@ export type DataType =
|
|
|
47
44
|
| "dates"
|
|
48
45
|
| "datetimes"
|
|
49
46
|
| "times"
|
|
50
|
-
export type FormatType = "currency" | "percentage" | "email" | "url" | "phone" | "fax" | "ipv4" | "ipv6"
|
|
51
|
-
export type MatchType = "equal" | "prefix" | "contain" | "max" | "min" // contain: default for string, min: default for Date, number
|
|
52
47
|
|
|
53
|
-
export interface Model {
|
|
54
|
-
name?: string
|
|
55
|
-
attributes: Attributes
|
|
56
|
-
source?: string
|
|
57
|
-
table?: string
|
|
58
|
-
collection?: string
|
|
59
|
-
model?: any
|
|
60
|
-
schema?: any
|
|
61
|
-
}
|
|
62
48
|
export interface Attribute {
|
|
63
49
|
name?: string
|
|
64
|
-
field?: string
|
|
65
50
|
column?: string
|
|
66
51
|
type?: DataType
|
|
67
|
-
format?: FormatType
|
|
68
|
-
required?: boolean
|
|
69
|
-
match?: MatchType
|
|
70
52
|
default?: string | number | Date | boolean
|
|
71
53
|
key?: boolean
|
|
72
|
-
unique?: boolean
|
|
73
|
-
enum?: string[] | number[]
|
|
74
|
-
q?: boolean
|
|
75
54
|
noinsert?: boolean
|
|
76
55
|
noupdate?: boolean
|
|
77
|
-
nopatch?: boolean
|
|
78
56
|
version?: boolean
|
|
79
|
-
length?: number
|
|
80
|
-
min?: number
|
|
81
|
-
max?: number
|
|
82
|
-
gt?: number
|
|
83
|
-
lt?: number
|
|
84
|
-
precision?: number
|
|
85
|
-
scale?: number
|
|
86
|
-
exp?: RegExp | string
|
|
87
|
-
code?: string
|
|
88
|
-
noformat?: boolean
|
|
89
57
|
ignored?: boolean
|
|
90
|
-
jsonField?: string
|
|
91
|
-
link?: string
|
|
92
|
-
typeof?: Attributes
|
|
93
58
|
true?: string | number
|
|
94
59
|
false?: string | number
|
|
95
|
-
getString?: (v: any) => string
|
|
96
60
|
}
|
|
97
61
|
export interface Attributes {
|
|
98
62
|
[key: string]: Attribute
|