index label ids on typesense

This commit is contained in:
Salihu
2026-08-17 15:50:16 +01:00
parent f702e826e7
commit 436f257ef7
4 changed files with 17 additions and 2 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ export class LabelService {
LabelType.PAGE,
trx,
);
await this.labelRepo.addLabelToPage(pageId, label.id, trx);
await this.labelRepo.addLabelToPage(pageId, label.id, workspaceId, trx);
attached.push(label);
}
});
@@ -8,6 +8,8 @@ import { PaginationOptions } from '@docmost/db/pagination/pagination-options';
import { executeWithCursorPagination } from '@docmost/db/pagination/cursor-pagination';
import { jsonArrayFrom, jsonObjectFrom } from 'kysely/helpers/postgres';
import { normalizeLabelName } from '../../../core/label/utils';
import { EventEmitter2 } from '@nestjs/event-emitter';
import { EventName } from 'src/common/events/event.contants';
export const LabelType = {
PAGE: 'page',
@@ -21,6 +23,7 @@ export class LabelRepo {
constructor(
@InjectKysely() private readonly db: KyselyDB,
private readonly spaceMemberRepo: SpaceMemberRepo,
private readonly eventEmitter: EventEmitter2,
) {}
async findById(
@@ -166,6 +169,7 @@ export class LabelRepo {
async addLabelToPage(
pageId: string,
labelId: string,
workspaceId: string,
trx?: KyselyTransaction,
): Promise<void> {
const db = dbOrTx(this.db, trx);
@@ -174,6 +178,11 @@ export class LabelRepo {
.values({ pageId, labelId })
.onConflict((oc) => oc.doNothing())
.execute();
this.eventEmitter.emit(EventName.PAGE_UPDATED, {
pageIds: [pageId],
workspaceId: workspaceId,
});
}
async removeLabelFromPage(
@@ -197,6 +206,11 @@ export class LabelRepo {
),
)
.execute();
this.eventEmitter.emit(EventName.PAGE_UPDATED, {
pageIds: [pageId],
workspaceId: workspaceId,
});
}
async getPageLabelCount(
+1
View File
@@ -312,6 +312,7 @@ export interface PageHistory {
export interface Pages {
content: Json | null;
contributorIds: Generated<string[] | null>;
labelIds: Generated<string[] | null>;
coverPhoto: string | null;
createdAt: Generated<Timestamp>;
creatorId: string | null;