mysql2 3.3.4 → 3.4.0
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/index.d.ts +26 -6
- package/lib/connection.js +3 -1
- package/lib/packets/resultset_header.js +7 -0
- package/package.json +4 -9
- package/promise.d.ts +159 -38
- package/typings/mysql/index.d.ts +74 -47
- package/typings/mysql/lib/Connection.d.ts +408 -293
- package/typings/mysql/lib/Pool.d.ts +178 -79
- package/typings/mysql/lib/PoolCluster.d.ts +58 -45
- package/typings/mysql/lib/PoolConnection.d.ts +4 -5
- package/typings/mysql/lib/Server.d.ts +4 -6
- package/typings/mysql/lib/protocol/packets/Field.d.ts +12 -13
- package/typings/mysql/lib/protocol/packets/FieldPacket.d.ts +18 -19
- package/typings/mysql/lib/protocol/packets/OkPacket.d.ts +12 -13
- package/typings/mysql/lib/protocol/packets/ResultSetHeader.d.ts +11 -12
- package/typings/mysql/lib/protocol/packets/RowDataPacket.d.ts +6 -7
- package/typings/mysql/lib/protocol/packets/index.d.ts +14 -15
- package/typings/mysql/lib/protocol/packets/params/ErrorPacketParams.d.ts +1 -1
- package/typings/mysql/lib/protocol/packets/params/OkPacketParams.d.ts +1 -1
- package/typings/mysql/lib/protocol/sequences/Prepare.d.ts +55 -42
- package/typings/mysql/lib/protocol/sequences/Query.d.ts +143 -142
- package/typings/mysql/lib/protocol/sequences/Sequence.d.ts +3 -3
|
@@ -1,52 +1,65 @@
|
|
|
1
|
-
import Sequence
|
|
2
|
-
import Query
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { Sequence } from './Sequence.js';
|
|
2
|
+
import { Query, QueryError, StreamOptions } from '../sequences/Query.js';
|
|
3
|
+
import {
|
|
4
|
+
OkPacket,
|
|
5
|
+
FieldPacket,
|
|
6
|
+
RowDataPacket,
|
|
7
|
+
ResultSetHeader,
|
|
8
|
+
} from '../packets/index.js';
|
|
9
|
+
import { Readable } from 'stream';
|
|
5
10
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
export class PrepareStatementInfo {
|
|
12
|
+
close(): void;
|
|
13
|
+
execute<
|
|
14
|
+
T extends
|
|
15
|
+
| RowDataPacket[][]
|
|
16
|
+
| RowDataPacket[]
|
|
17
|
+
| OkPacket
|
|
18
|
+
| OkPacket[]
|
|
19
|
+
| ResultSetHeader
|
|
20
|
+
>(
|
|
21
|
+
paramaters: any | any[] | { [param: string]: any },
|
|
22
|
+
callback?: (err: QueryError | null, result: T, fields: FieldPacket[]) => any
|
|
23
|
+
): Query;
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
declare class Prepare extends Sequence {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
/**
|
|
28
|
+
* The SQL for a constructed query
|
|
29
|
+
*/
|
|
30
|
+
sql: string;
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Emits a query packet to start the query
|
|
34
|
+
*/
|
|
35
|
+
start(): void;
|
|
29
36
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Determines the packet class to use given the first byte of the packet.
|
|
39
|
+
*
|
|
40
|
+
* @param firstByte The first byte of the packet
|
|
41
|
+
* @param parser The packet parser
|
|
42
|
+
*/
|
|
43
|
+
determinePacket(firstByte: number, parser: any): any;
|
|
37
44
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Creates a Readable stream with the given options
|
|
47
|
+
*
|
|
48
|
+
* @param options The options for the stream.
|
|
49
|
+
*/
|
|
50
|
+
stream(options?: StreamOptions): Readable;
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
on(event: string, listener: (args: []) => void): this;
|
|
53
|
+
on(event: 'error', listener: (err: QueryError) => any): this;
|
|
54
|
+
on(
|
|
55
|
+
event: 'fields',
|
|
56
|
+
listener: (fields: FieldPacket, index: number) => any
|
|
57
|
+
): this;
|
|
58
|
+
on(
|
|
59
|
+
event: 'result',
|
|
60
|
+
listener: (result: RowDataPacket | OkPacket, index: number) => any
|
|
61
|
+
): this;
|
|
62
|
+
on(event: 'end', listener: () => any): this;
|
|
50
63
|
}
|
|
51
64
|
|
|
52
|
-
export
|
|
65
|
+
export { Prepare };
|
|
@@ -1,148 +1,149 @@
|
|
|
1
|
+
import { Sequence } from './Sequence.js';
|
|
2
|
+
import { OkPacket, RowDataPacket, FieldPacket } from '../packets/index.js';
|
|
3
|
+
import { Readable } from 'stream';
|
|
4
|
+
|
|
5
|
+
export interface QueryOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The SQL for the query
|
|
8
|
+
*/
|
|
9
|
+
sql: string;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The values for the query
|
|
13
|
+
*/
|
|
14
|
+
values?: any | any[] | { [param: string]: any };
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* This overrides the namedPlaceholders option set at the connection level.
|
|
18
|
+
*/
|
|
19
|
+
namedPlaceholders?: boolean;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Every operation takes an optional inactivity timeout option. This allows you to specify appropriate timeouts for
|
|
23
|
+
* operations. It is important to note that these timeouts are not part of the MySQL protocol, and rather timeout
|
|
24
|
+
* operations through the client. This means that when a timeout is reached, the connection it occurred on will be
|
|
25
|
+
* destroyed and no further operations can be performed.
|
|
26
|
+
*/
|
|
27
|
+
timeout?: number;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Either a boolean or string. If true, tables will be nested objects. If string (e.g. '_'), tables will be
|
|
31
|
+
* nested as tableName_fieldName
|
|
32
|
+
*/
|
|
33
|
+
nestTables?: any;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Determines if column values should be converted to native JavaScript types. It is not recommended (and may go away / change in the future)
|
|
37
|
+
* to disable type casting, but you can currently do so on either the connection or query level. (Default: true)
|
|
38
|
+
*
|
|
39
|
+
* You can also specify a function (field: any, next: () => void) => {} to do the type casting yourself.
|
|
40
|
+
*
|
|
41
|
+
* WARNING: YOU MUST INVOKE the parser using one of these three field functions in your custom typeCast callback. They can only be called once.
|
|
42
|
+
*
|
|
43
|
+
* field.string()
|
|
44
|
+
* field.buffer()
|
|
45
|
+
* field.geometry()
|
|
46
|
+
*
|
|
47
|
+
* are aliases for
|
|
48
|
+
*
|
|
49
|
+
* parser.parseLengthCodedString()
|
|
50
|
+
* parser.parseLengthCodedBuffer()
|
|
51
|
+
* parser.parseGeometryValue()
|
|
52
|
+
*
|
|
53
|
+
* You can find which field function you need to use by looking at: RowDataPacket.prototype._typeCast
|
|
54
|
+
*/
|
|
55
|
+
typeCast?: any;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* This overrides the same option set at the connection level.
|
|
59
|
+
*
|
|
60
|
+
*/
|
|
61
|
+
rowsAsArray?: boolean;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* By specifying a function that returns a readable stream, an arbitrary stream can be sent when sending a local fs file.
|
|
65
|
+
*/
|
|
66
|
+
infileStreamFactory?: (path: string) => Readable;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface StreamOptions {
|
|
70
|
+
/**
|
|
71
|
+
* Sets the max buffer size in objects of a stream
|
|
72
|
+
*/
|
|
73
|
+
highWaterMark?: number;
|
|
1
74
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
declare namespace Query {
|
|
7
|
-
|
|
8
|
-
export interface QueryOptions {
|
|
9
|
-
/**
|
|
10
|
-
* The SQL for the query
|
|
11
|
-
*/
|
|
12
|
-
sql: string;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The values for the query
|
|
16
|
-
*/
|
|
17
|
-
values?: any | any[] | { [param: string]: any };
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* This overrides the namedPlaceholders option set at the connection level.
|
|
21
|
-
*/
|
|
22
|
-
namedPlaceholders?: boolean;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Every operation takes an optional inactivity timeout option. This allows you to specify appropriate timeouts for
|
|
26
|
-
* operations. It is important to note that these timeouts are not part of the MySQL protocol, and rather timeout
|
|
27
|
-
* operations through the client. This means that when a timeout is reached, the connection it occurred on will be
|
|
28
|
-
* destroyed and no further operations can be performed.
|
|
29
|
-
*/
|
|
30
|
-
timeout?: number;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Either a boolean or string. If true, tables will be nested objects. If string (e.g. '_'), tables will be
|
|
34
|
-
* nested as tableName_fieldName
|
|
35
|
-
*/
|
|
36
|
-
nestTables?: any;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Determines if column values should be converted to native JavaScript types. It is not recommended (and may go away / change in the future)
|
|
40
|
-
* to disable type casting, but you can currently do so on either the connection or query level. (Default: true)
|
|
41
|
-
*
|
|
42
|
-
* You can also specify a function (field: any, next: () => void) => {} to do the type casting yourself.
|
|
43
|
-
*
|
|
44
|
-
* WARNING: YOU MUST INVOKE the parser using one of these three field functions in your custom typeCast callback. They can only be called once.
|
|
45
|
-
*
|
|
46
|
-
* field.string()
|
|
47
|
-
* field.buffer()
|
|
48
|
-
* field.geometry()
|
|
49
|
-
*
|
|
50
|
-
* are aliases for
|
|
51
|
-
*
|
|
52
|
-
* parser.parseLengthCodedString()
|
|
53
|
-
* parser.parseLengthCodedBuffer()
|
|
54
|
-
* parser.parseGeometryValue()
|
|
55
|
-
*
|
|
56
|
-
* You can find which field function you need to use by looking at: RowDataPacket.prototype._typeCast
|
|
57
|
-
*/
|
|
58
|
-
typeCast?: any;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* This overrides the same option set at the connection level.
|
|
62
|
-
*
|
|
63
|
-
*/
|
|
64
|
-
rowsAsArray?: boolean
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* By specifying a function that returns a readable stream, an arbitrary stream can be sent when sending a local fs file.
|
|
68
|
-
*/
|
|
69
|
-
infileStreamFactory?: (path: string) => Readable;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface StreamOptions {
|
|
73
|
-
/**
|
|
74
|
-
* Sets the max buffer size in objects of a stream
|
|
75
|
-
*/
|
|
76
|
-
highWaterMark?: number;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* The object mode of the stream (Default: true)
|
|
80
|
-
*/
|
|
81
|
-
objectMode?: any;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export interface QueryError extends NodeJS.ErrnoException {
|
|
85
|
-
/**
|
|
86
|
-
* Either a MySQL server error (e.g. 'ER_ACCESS_DENIED_ERROR'),
|
|
87
|
-
* a node.js error (e.g. 'ECONNREFUSED') or an internal error
|
|
88
|
-
* (e.g. 'PROTOCOL_CONNECTION_LOST').
|
|
89
|
-
*/
|
|
90
|
-
code: string;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* The sql state marker
|
|
94
|
-
*/
|
|
95
|
-
sqlStateMarker?: string;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* The sql state
|
|
99
|
-
*/
|
|
100
|
-
sqlState?: string;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* The field count
|
|
104
|
-
*/
|
|
105
|
-
fieldCount?: number;
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Boolean, indicating if this error is terminal to the connection object.
|
|
109
|
-
*/
|
|
110
|
-
fatal: boolean;
|
|
111
|
-
}
|
|
75
|
+
/**
|
|
76
|
+
* The object mode of the stream (Default: true)
|
|
77
|
+
*/
|
|
78
|
+
objectMode?: any;
|
|
112
79
|
}
|
|
113
80
|
|
|
114
|
-
|
|
81
|
+
export interface QueryError extends NodeJS.ErrnoException {
|
|
82
|
+
/**
|
|
83
|
+
* Either a MySQL server error (e.g. 'ER_ACCESS_DENIED_ERROR'),
|
|
84
|
+
* a node.js error (e.g. 'ECONNREFUSED') or an internal error
|
|
85
|
+
* (e.g. 'PROTOCOL_CONNECTION_LOST').
|
|
86
|
+
*/
|
|
87
|
+
code: string;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The sql state marker
|
|
91
|
+
*/
|
|
92
|
+
sqlStateMarker?: string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The sql state
|
|
96
|
+
*/
|
|
97
|
+
sqlState?: string;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The field count
|
|
101
|
+
*/
|
|
102
|
+
fieldCount?: number;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Boolean, indicating if this error is terminal to the connection object.
|
|
106
|
+
*/
|
|
107
|
+
fatal: boolean;
|
|
108
|
+
}
|
|
115
109
|
|
|
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
|
-
|
|
110
|
+
declare class Query extends Sequence {
|
|
111
|
+
/**
|
|
112
|
+
* The SQL for a constructed query
|
|
113
|
+
*/
|
|
114
|
+
sql: string;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Emits a query packet to start the query
|
|
118
|
+
*/
|
|
119
|
+
start(): void;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Determines the packet class to use given the first byte of the packet.
|
|
123
|
+
*
|
|
124
|
+
* @param firstByte The first byte of the packet
|
|
125
|
+
* @param parser The packet parser
|
|
126
|
+
*/
|
|
127
|
+
determinePacket(firstByte: number, parser: any): any;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Creates a Readable stream with the given options
|
|
131
|
+
*
|
|
132
|
+
* @param options The options for the stream.
|
|
133
|
+
*/
|
|
134
|
+
stream(options?: StreamOptions): Readable;
|
|
135
|
+
|
|
136
|
+
on(event: string, listener: (args: any[]) => void): this;
|
|
137
|
+
on(event: 'error', listener: (err: QueryError) => any): this;
|
|
138
|
+
on(
|
|
139
|
+
event: 'fields',
|
|
140
|
+
listener: (fields: FieldPacket, index: number) => any
|
|
141
|
+
): this;
|
|
142
|
+
on(
|
|
143
|
+
event: 'result',
|
|
144
|
+
listener: (result: RowDataPacket | OkPacket, index: number) => any
|
|
145
|
+
): this;
|
|
146
|
+
on(event: 'end', listener: () => any): this;
|
|
146
147
|
}
|
|
147
148
|
|
|
148
|
-
export
|
|
149
|
+
export { Query };
|