From 84d67438638729cca75d4e0e320b81283badb8c7 Mon Sep 17 00:00:00 2001 From: Mathis Date: Tue, 8 Oct 2024 16:08:50 +0200 Subject: [PATCH] Add getFilesTypes method to machines service Implemented a new method to retrieve file types associated with a specific machine by its ID. This method queries the database and returns a promise that resolves to an array of file types. --- apps/backend/src/app/machines/machines.service.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/backend/src/app/machines/machines.service.ts b/apps/backend/src/app/machines/machines.service.ts index 04d5337..ca84f31 100644 --- a/apps/backend/src/app/machines/machines.service.ts +++ b/apps/backend/src/app/machines/machines.service.ts @@ -160,8 +160,20 @@ export class MachinesService { .execute(); } + /** + * Retrieves the file types associated with a specific machine based on the given machine ID. + * + * @param {string} machineId - The unique identifier of the machine whose file types are to be retrieved. + * @return {Promise>} A promise that resolves to an array of file types associated with the machine. + */ async getFilesTypes(machineId: string) { - //TODO Find machineId and associated filesTypes + return this.database + .use() + .select() + .from(FilesTypeForMachine) + .where(eq(FilesTypeForMachine.machineId, machineId)) + .prepare("getMachineFilesTypesById") + .execute(); } /**