Add search method to Files Service

Implemented a method to search for files in the database by limit, offset, and search term. This method enhances the service by providing a way to paginate and filter file results.
This commit is contained in:
Mathis H (Avnyr) 2024-10-17 12:21:58 +02:00
parent 7b4792b612
commit 38634132ba
Signed by: Mathis
GPG Key ID: DD9E0666A747D126

View File

@ -123,6 +123,14 @@ export class FilesService {
}
}
/**
* Searches for files in the database based on the provided search field, limit, and offset.
*
* @param {number} limit - The maximum number of results to return.
* @param {number} offset - The offset for the results.
* @param {string} searchField - The value to search for within the file names.
* @return {Promise<IWithCount<IFileTable>>} 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<IWithCount<IFileTable>> {
try {
const countResult = await this.database.use()