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(); + } }