diff --git a/apps/backend/src/app/files/files.service.ts b/apps/backend/src/app/files/files.service.ts index 18d2242..a895ae9 100644 --- a/apps/backend/src/app/files/files.service.ts +++ b/apps/backend/src/app/files/files.service.ts @@ -11,11 +11,13 @@ import { FilesGroupTable, FilesTable, FilesTypeForMachine, - FilesTypesTable, IFileTable, IWithCount, - MachinesTable -} from 'apps/backend/src/app/db/schema'; + FilesTypesTable, + IFileTable, + IWithCount, + MachinesTable, +} from "apps/backend/src/app/db/schema"; import { StorageService } from "apps/backend/src/app/storage/storage.service"; -import { count, eq, ilike } from 'drizzle-orm'; +import { count, eq, ilike } from "drizzle-orm"; @Injectable() export class FilesService { @@ -131,13 +133,19 @@ export class FilesService { * @param {string} searchField - The value to search for within the file names. * @return {Promise>} A promise that resolves to an object containing the count of files that match the search criteria, the provided limit, the current offset, and the matching data. */ - public async search(limit: number, offset: number, searchField: string): Promise> { + public async search( + limit: number, + offset: number, + searchField: string, + ): Promise> { try { - const countResult = await this.database.use() - .select({count : count()}) - .from(FilesTable).where(ilike(FilesTable.fileName, String(`%${searchField}%`))) + const countResult = await this.database + .use() + .select({ count: count() }) + .from(FilesTable) + .where(ilike(FilesTable.fileName, String(`%${searchField}%`))) .prepare("searchFilesCount") - .execute() + .execute(); const dataResult = await this.database .use() .select() @@ -151,8 +159,8 @@ export class FilesService { count: countResult[0].count, limit: limit, currentOffset: offset, - data: dataResult - } + data: dataResult, + }; } catch (error) { throw new InternalServerErrorException(error); }