Skip to content

Commit c4153b0

Browse files
committed
up
1 parent 236899b commit c4153b0

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/DataAPI/DataBase.d.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,16 @@ declare class DBSession {
107107
* @param sql 要准备的SQL语句
108108
* @returns DBStmt 预准备语句,失败抛出错误
109109
*/
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>
111113
}
112114

113115
/** 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+
> {
115120
/**
116121
* 获取该预准备语句执行后影响的行数 (仅对 `INSERT` `UPDATE` `DELETE` `REPLACE` 等语句生效)
117122
*/
@@ -127,29 +132,29 @@ declare class DBStmt<T extends Record<string, any> = any> {
127132
* @param val 要绑定的值
128133
* @tips 本重载将会将值绑定到第一个未绑定的参数上
129134
*/
130-
bind(val: T[keyof T]): void
135+
bind(val: P[keyof P]): void
131136

132137
/**
133138
* 绑定参数到一个SQL语句
134139
* @param val 要绑定的值
135140
* @tips 要绑定的对象,等同于遍历此对象并执行
136141
* @tips 对于Object:bind(val, key) 对于Array:bind(val)
137142
*/
138-
bind(val: T | T[keyof T][]): void
143+
bind(val: P | P[keyof P][]): void
139144

140145
/**
141146
* 绑定参数到一个SQL语句
142147
* @param val 要绑定的值
143148
* @param index 要绑定到的参数索引(从`0`开始)
144149
*/
145-
bind(val: T[keyof T], index: number): void
150+
bind(val: P[keyof P], index: number): void
146151

147152
/**
148153
* 绑定参数到一个SQL语句
149154
* @param val 要绑定的值
150155
* @param name 要绑定到的参数的参数名
151156
*/
152-
bind(val: T[keyof T], name: string): void
157+
bind(val: P[keyof P], name: string): void
153158

154159
/**
155160
* 执行SQL但不获取结果

0 commit comments

Comments
 (0)