mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 04:46:05 +00:00
public commit
This commit is contained in:
23
app/src/data/plugins/KyselyPluginRunner.ts
Normal file
23
app/src/data/plugins/KyselyPluginRunner.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { KyselyPlugin, UnknownRow } from "kysely";
|
||||
|
||||
// @todo: add test
|
||||
export class KyselyPluginRunner {
|
||||
protected plugins: Set<KyselyPlugin>;
|
||||
|
||||
constructor(plugins: KyselyPlugin[] = []) {
|
||||
this.plugins = new Set(plugins);
|
||||
}
|
||||
|
||||
async transformResultRows<T>(rows: T[]): Promise<T[]> {
|
||||
let copy = rows;
|
||||
for (const plugin of this.plugins) {
|
||||
const res = await plugin.transformResult({
|
||||
queryId: "1" as any,
|
||||
result: { rows: copy as UnknownRow[] },
|
||||
});
|
||||
copy = res.rows as T[];
|
||||
}
|
||||
|
||||
return copy as T[];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user