Skip to content

Commit

Permalink
- Fix the types.
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennenoel committed Jun 7, 2024
1 parent adad90b commit d00e7c1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
14 changes: 10 additions & 4 deletions packages/mysql-common/src/models/search-query.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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(","),
Expand Down

0 comments on commit d00e7c1

Please sign in to comment.