@@ -107,11 +107,16 @@ declare class DBSession {
107
107
* @param sql 要准备的SQL语句
108
108
* @returns DBStmt 预准备语句,失败抛出错误
109
109
*/
110
- prepare < T extends Record < string , any > > ( sql : string ) : DBStmt < T >
110
+ prepare < T extends Record < string , any > , P extends Record < string , any > > (
111
+ sql : string ,
112
+ ) : DBStmt < T , P >
111
113
}
112
114
113
115
/** SQL预准备语句 */
114
- declare class DBStmt < T extends Record < string , any > = any > {
116
+ declare class DBStmt <
117
+ T extends Record < string , any > = any ,
118
+ P extends Record < string , any > = any ,
119
+ > {
115
120
/**
116
121
* 获取该预准备语句执行后影响的行数 (仅对 `INSERT` `UPDATE` `DELETE` `REPLACE` 等语句生效)
117
122
*/
@@ -127,29 +132,29 @@ declare class DBStmt<T extends Record<string, any> = any> {
127
132
* @param val 要绑定的值
128
133
* @tips 本重载将会将值绑定到第一个未绑定的参数上
129
134
*/
130
- bind ( val : T [ keyof T ] ) : void
135
+ bind ( val : P [ keyof P ] ) : void
131
136
132
137
/**
133
138
* 绑定参数到一个SQL语句
134
139
* @param val 要绑定的值
135
140
* @tips 要绑定的对象,等同于遍历此对象并执行
136
141
* @tips 对于Object:bind(val, key) 对于Array:bind(val)
137
142
*/
138
- bind ( val : T | T [ keyof T ] [ ] ) : void
143
+ bind ( val : P | P [ keyof P ] [ ] ) : void
139
144
140
145
/**
141
146
* 绑定参数到一个SQL语句
142
147
* @param val 要绑定的值
143
148
* @param index 要绑定到的参数索引(从`0`开始)
144
149
*/
145
- bind ( val : T [ keyof T ] , index : number ) : void
150
+ bind ( val : P [ keyof P ] , index : number ) : void
146
151
147
152
/**
148
153
* 绑定参数到一个SQL语句
149
154
* @param val 要绑定的值
150
155
* @param name 要绑定到的参数的参数名
151
156
*/
152
- bind ( val : T [ keyof T ] , name : string ) : void
157
+ bind ( val : P [ keyof P ] , name : string ) : void
153
158
154
159
/**
155
160
* 执行SQL但不获取结果
0 commit comments