Skip to content

Commit 9a2080e

Browse files
committed
fix: fix create webhook
1 parent 499eda5 commit 9a2080e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

packages/persistence/src/webhook/webhook.repository.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { inject, singleton } from "@undb/di"
22
import { None, Some, type Option } from "@undb/domain"
33
import { type IWebhookRepository, type WebhookDo, type WebhookSpecification } from "@undb/webhook"
4+
import { getCurrentTransaction } from "../ctx"
45
import type { IQueryBuilder } from "../qb"
56
import { injectQueryBuilder } from "../qb.provider"
67
import { WebhookFilterVisitor } from "./webhook.filter-visitor"
@@ -17,7 +18,7 @@ export class WebhookRepository implements IWebhookRepository {
1718
) {}
1819

1920
async findOneById(id: string): Promise<Option<WebhookDo>> {
20-
const wb = await this.qb
21+
const wb = await (getCurrentTransaction() ?? this.qb)
2122
.selectFrom("undb_webhook")
2223
.selectAll()
2324
.where((eb) => eb.eb("id", "=", id))
@@ -31,7 +32,7 @@ export class WebhookRepository implements IWebhookRepository {
3132
}
3233

3334
async find(spec: WebhookSpecification): Promise<WebhookDo[]> {
34-
const wb = await this.qb
35+
const wb = await (getCurrentTransaction() ?? this.qb)
3536
.selectFrom("undb_webhook")
3637
.selectAll()
3738
.where((eb) => {
@@ -47,14 +48,14 @@ export class WebhookRepository implements IWebhookRepository {
4748
async insert(webhook: WebhookDo): Promise<void> {
4849
const values = this.mapper.toEntity(webhook)
4950

50-
await this.qb.insertInto("undb_webhook").values(values).execute()
51+
await (getCurrentTransaction() ?? this.qb).insertInto("undb_webhook").values(values).execute()
5152
}
5253

5354
async updateOneById(webhook: WebhookDo, spec: WebhookSpecification): Promise<void> {
5455
const visitor = new WebhookMutationVisitor()
5556
spec.accept(visitor)
5657

57-
await this.qb
58+
await (getCurrentTransaction() ?? this.qb)
5859
.updateTable("undb_webhook")
5960
.set(visitor.data)
6061
.where((eb) => eb.eb("id", "=", webhook.id.value))

0 commit comments

Comments
 (0)