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