From deea99d8651a586a6d9fbd42afa6e225c5920674 Mon Sep 17 00:00:00 2001 From: Mythie Date: Tue, 25 Feb 2025 09:44:40 +1100 Subject: [PATCH] feat: search by externalId --- .../server-only/document/find-documents.ts | 1 + .../document/search-documents-with-keyword.ts | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/packages/lib/server-only/document/find-documents.ts b/packages/lib/server-only/document/find-documents.ts index f6e234dea..f3e7d772a 100644 --- a/packages/lib/server-only/document/find-documents.ts +++ b/packages/lib/server-only/document/find-documents.ts @@ -81,6 +81,7 @@ export const findDocuments = async ({ const searchFilter: Prisma.DocumentWhereInput = { OR: [ { title: { contains: query, mode: 'insensitive' } }, + { externalId: { contains: query, mode: 'insensitive' } }, { recipients: { some: { name: { contains: query, mode: 'insensitive' } } } }, { recipients: { some: { email: { contains: query, mode: 'insensitive' } } } }, ], diff --git a/packages/lib/server-only/document/search-documents-with-keyword.ts b/packages/lib/server-only/document/search-documents-with-keyword.ts index 7970c19bd..8982188cd 100644 --- a/packages/lib/server-only/document/search-documents-with-keyword.ts +++ b/packages/lib/server-only/document/search-documents-with-keyword.ts @@ -34,6 +34,14 @@ export const searchDocumentsWithKeyword = async ({ userId: userId, deletedAt: null, }, + { + externalId: { + contains: query, + mode: 'insensitive', + }, + userId: userId, + deletedAt: null, + }, { recipients: { some: { @@ -88,6 +96,23 @@ export const searchDocumentsWithKeyword = async ({ }, deletedAt: null, }, + { + externalId: { + contains: query, + mode: 'insensitive', + }, + teamId: { + not: null, + }, + team: { + members: { + some: { + userId: userId, + }, + }, + }, + deletedAt: null, + }, ], }, include: {