From d53054a26763916325841d9da7899f77047a3c14 Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Sat, 23 May 2026 02:01:06 +0100 Subject: [PATCH] feat(integrations): add findByTypeAndSettingsField for JSONB lookup --- .../core/integration/repos/integration.repo.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/apps/server/src/core/integration/repos/integration.repo.ts b/apps/server/src/core/integration/repos/integration.repo.ts index 2969aa786..6642fc067 100644 --- a/apps/server/src/core/integration/repos/integration.repo.ts +++ b/apps/server/src/core/integration/repos/integration.repo.ts @@ -1,5 +1,6 @@ import { Injectable } from '@nestjs/common'; import { InjectKysely } from 'nestjs-kysely'; +import { sql } from 'kysely'; import { KyselyDB, KyselyTransaction } from '@docmost/db/types/kysely.types'; import { Integration, @@ -124,4 +125,19 @@ export class IntegrationRepo { .where('id', '=', integrationId) .execute(); } + + async findByTypeAndSettingsField( + type: string, + key: string, + value: string, + ): Promise { + return this.db + .selectFrom('integrations') + .selectAll() + .where('type', '=', type) + .where('isEnabled', '=', true) + .where('deletedAt', 'is', null) + .where(sql`settings->>${sql.lit(key)}`, '=', value) + .executeTakeFirst(); + } }