mirror of
https://github.com/docmost/docmost.git
synced 2026-08-21 06:41:37 +10:00
feat(integrations): add findByTypeAndSettingsField for JSONB lookup
This commit is contained in:
@@ -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<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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user