Compare commits
2 Commits
6600c6310a
...
289ec09868
Author | SHA1 | Date | |
---|---|---|---|
289ec09868 | |||
52870aeb0d |
@ -29,7 +29,7 @@ export class AuthorsController {
|
|||||||
|
|
||||||
@UseGuards(AdminGuard)
|
@UseGuards(AdminGuard)
|
||||||
@Delete(":autor")
|
@Delete(":autor")
|
||||||
async deleteAuthor(@Param("machineId") machineId: string) {}
|
async deleteAuthor(@Param("author") author: string) {}
|
||||||
|
|
||||||
//TODO Patch
|
//TODO Patch
|
||||||
|
|
||||||
|
@ -1,11 +1,35 @@
|
|||||||
import { Injectable } from "@nestjs/common";
|
import { Injectable } from "@nestjs/common";
|
||||||
import { DbService } from "apps/backend/src/app/db/db.service";
|
import { DbService } from "apps/backend/src/app/db/db.service";
|
||||||
|
import { MachinesTable } from "apps/backend/src/app/db/schema";
|
||||||
|
import { ilike } from "drizzle-orm";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MachinesService {
|
export class MachinesService {
|
||||||
constructor(private readonly database: DbService) {}
|
constructor(private readonly database: DbService) {}
|
||||||
|
|
||||||
//TODO a method to fetch machines in the database by a specific search with limit, offset and a search field (can be blank)
|
/**
|
||||||
|
* Finds and returns a list of machines based on the given search parameters.
|
||||||
|
*
|
||||||
|
* @param {number} limit - The maximum number of machines to return.
|
||||||
|
* @param {number} offset - The number of machines to skip before starting to collect the result set.
|
||||||
|
* @param {string} searchField - The field to search within the machine names.
|
||||||
|
*
|
||||||
|
* @return {Promise<Array>} A promise that resolves to an array of found machines.
|
||||||
|
*/
|
||||||
|
async findMany(limit: number, offset: number, searchField: string) {
|
||||||
|
console.log(`Searching machines. \nSearch : ${searchField}`);
|
||||||
|
const machines = await this.database
|
||||||
|
.use()
|
||||||
|
.select()
|
||||||
|
.from(MachinesTable)
|
||||||
|
.where(ilike(MachinesTable.machineName, String(`%${searchField}%`)))
|
||||||
|
.limit(limit)
|
||||||
|
.offset(offset)
|
||||||
|
.prepare("findMachineByName")
|
||||||
|
.execute();
|
||||||
|
console.log(`Found ${machines.length} machines.`);
|
||||||
|
return machines;
|
||||||
|
}
|
||||||
|
|
||||||
//TODO The method to create a machine
|
//TODO The method to create a machine
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user