diff --git a/packages/mysql-common/src/interfaces/search-query-parameters.interface.ts b/packages/mysql-common/src/interfaces/search-query-parameters.interface.ts index 1d20a99a..9560af24 100644 --- a/packages/mysql-common/src/interfaces/search-query-parameters.interface.ts +++ b/packages/mysql-common/src/interfaces/search-query-parameters.interface.ts @@ -14,7 +14,7 @@ export interface SearchQueryParametersInterface { /** * The page number to retrieve. */ - page?: number; + page?: string; /** * Comma separated list of field to consider in the search. @@ -24,7 +24,7 @@ export interface SearchQueryParametersInterface { /** * The maximum number of results per page to return. */ - maximumNumberOfResultsPerPage?: number; + maximumNumberOfResultsPerPage?: string; /** * Separated by commas string of `field:asc|desc` to sort the results. diff --git a/packages/mysql-common/src/models/search-query.model.ts b/packages/mysql-common/src/models/search-query.model.ts index 9a0320fa..070ca31e 100644 --- a/packages/mysql-common/src/models/search-query.model.ts +++ b/packages/mysql-common/src/models/search-query.model.ts @@ -108,8 +108,14 @@ export class SearchQuery { } this.query = queryStrings.query ?? this.query; - this.page = queryStrings.page ?? this.page; - this.maximumNumberOfResultsPerPage = queryStrings.maximumNumberOfResultsPerPage ?? this.maximumNumberOfResultsPerPage; + if(queryStrings.page) { + this.page = parseInt(queryStrings.page); + } + + if(queryStrings.maximumNumberOfResultsPerPage) { + this.maximumNumberOfResultsPerPage = parseInt(queryStrings.maximumNumberOfResultsPerPage); + } + if(queryStrings.fields) { this.fields = queryStrings.fields?.split(",").map((field) => new SearchQueryField(field, {includeExplicitly: true})) ?? this.fields; } @@ -162,8 +168,8 @@ export class SearchQuery { exportQueryParameters(): SearchQueryParametersInterface { return { query: this.query, - page: this.page, - maximumNumberOfResultsPerPage: this.maximumNumberOfResultsPerPage, + page: this.page + "", + maximumNumberOfResultsPerPage: this.maximumNumberOfResultsPerPage + "", excludeFieldsFromResponse: this.fields.filter((field) => field.exclude).map((field) => field.field).join(","), fields: this.fields.filter((field) => field.includeExplicitly).map((field) => field.field).join(","), sort: this.fields.filter((field) => field.order !== undefined).map((field) => `${field.field}:${field.order}`).join(","),