feat(integrations): add findByTypeAndSettingsField for JSONB lookup

This commit is contained in:
Philipinho
2026-05-23 02:01:06 +01:00
parent a1f6aa1e43
commit d53054a267
@@ -1,5 +1,6 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { InjectKysely } from 'nestjs-kysely'; import { InjectKysely } from 'nestjs-kysely';
import { sql } from 'kysely';
import { KyselyDB, KyselyTransaction } from '@docmost/db/types/kysely.types'; import { KyselyDB, KyselyTransaction } from '@docmost/db/types/kysely.types';
import { import {
Integration, Integration,
@@ -124,4 +125,19 @@ export class IntegrationRepo {
.where('id', '=', integrationId) .where('id', '=', integrationId)
.execute(); .execute();
} }
async findByTypeAndSettingsField(
type: string,
key: string,
value: string,
): Promise<Integration | undefined> {
return this.db
.selectFrom('integrations')
.selectAll()
.where('type', '=', type)
.where('isEnabled', '=', true)
.where('deletedAt', 'is', null)
.where(sql<string>`settings->>${sql.lit(key)}`, '=', value)
.executeTakeFirst();
}
} }