fix sync events not awaited (#164)

This commit is contained in:
dswbx
2025-04-25 22:36:19 -07:00
committed by GitHub
parent f04239332a
commit b60fd01960
2 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ export async function getFresh<Env extends CloudflareEnv = CloudflareEnv>(
...config, ...config,
onBuilt: async (app) => { onBuilt: async (app) => {
registerAsyncsExecutionContext(app, ctx.ctx); registerAsyncsExecutionContext(app, ctx.ctx);
config.onBuilt?.(app); await config.onBuilt?.(app);
}, },
}, },
ctx.env, ctx.env,
+5 -5
View File
@@ -330,10 +330,10 @@ export class Repository<TBD extends object = DefaultDB, TB extends keyof TBD = a
qb: RepositoryQB, qb: RepositoryQB,
options: RepoQuery, options: RepoQuery,
): Promise<RepositoryResponse<EntityData>> { ): Promise<RepositoryResponse<EntityData>> {
this.triggerFindBefore(this.entity, options); await this.triggerFindBefore(this.entity, options);
const { data, ...response } = await this.performQuery(qb); const { data, ...response } = await this.performQuery(qb);
this.triggerFindAfter(this.entity, options, data); await this.triggerFindAfter(this.entity, options, data);
return { ...response, data: data[0]! }; return { ...response, data: data[0]! };
} }
@@ -434,16 +434,16 @@ export class Repository<TBD extends object = DefaultDB, TB extends keyof TBD = a
limit: 1, limit: 1,
}); });
return this.single(qb, options) as any; return (await this.single(qb, options)) as any;
} }
async findMany(_options?: Partial<RepoQuery>): Promise<RepositoryResponse<TBD[TB][]>> { async findMany(_options?: Partial<RepoQuery>): Promise<RepositoryResponse<TBD[TB][]>> {
const { qb, options } = this.buildQuery(_options); const { qb, options } = this.buildQuery(_options);
this.triggerFindBefore(this.entity, options); await this.triggerFindBefore(this.entity, options);
const res = await this.performQuery(qb); const res = await this.performQuery(qb);
this.triggerFindAfter(this.entity, options, res.data); await this.triggerFindAfter(this.entity, options, res.data);
return res as any; return res as any;
} }