Skip to content

Commit b125f14

Browse files
committed
feat(builder): remove executeCompiled & executeCompiledTakeList, please use execute
1 parent 1a899f9 commit b125f14

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

packages/sqlite-builder/src/builder.ts

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,18 @@ export class SqliteBuilder<DB extends Record<string, any>> {
180180
* execute and return result list,
181181
* auto detect transaction, auto catch error
182182
*/
183+
public async execute<O>(
184+
query: CompiledQuery<O>,
185+
): Promise<QueryResult<O>>
183186
public async execute<O>(
184187
fn: (db: Kysely<DB> | Transaction<DB>) => AvailableBuilder<DB, O>,
185-
): Promise<Simplify<O>[] | undefined> {
186-
return await fn(this.getDB()).execute()
188+
): Promise<Simplify<O>[] | undefined>
189+
public async execute<O>(
190+
data: CompiledQuery<O> | ((db: Kysely<DB> | Transaction<DB>) => AvailableBuilder<DB, O>),
191+
): Promise<QueryResult<O> | Simplify<O>[] | undefined> {
192+
return typeof data === 'function'
193+
? await data(this.getDB()).execute()
194+
: await this.getDB().executeQuery(data)
187195
}
188196

189197
/**
@@ -214,26 +222,6 @@ export class SqliteBuilder<DB extends Record<string, any>> {
214222
return precompileQuery(queryBuilder(this.kysely), this.serializer)
215223
}
216224

217-
/**
218-
* exec compiled query, return result,
219-
* auto detect transaction, auto catch error
220-
*/
221-
public async executeCompiled<O>(
222-
query: CompiledQuery<O>,
223-
): Promise<QueryResult<O>> {
224-
return await this.getDB().executeQuery(query)
225-
}
226-
227-
/**
228-
* run {@link execCompiled} and get its rows,
229-
* auto detect transaction, auto catch error
230-
*/
231-
public async executeCompiledTakeList<O>(
232-
query: CompiledQuery<O>,
233-
): Promise<O[]> {
234-
return (await this.executeCompiled(query)).rows
235-
}
236-
237225
/**
238226
* execute raw sql,
239227
* auto detect transaction, auto catch error

0 commit comments

Comments
 (0)