Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: flatten only arrayble search params before search #214

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tharropoulos
Copy link
Contributor

Change Summary

Introduces a new utility function and types for only checking search parameters that can be either a base type, or an array of said type. Instead of checking through all of the possible parameters (more than 50), it instead iterates over a specific part (10), improving performance and ensuring maintainability, if non-search parameters should still retain their original array format in the future.

PR Checklist

Introduces a new utility type, ArrayableSearchParams, and a constant,
searchParamsArrayKeys. The ArrayableSearchParams typefilters the
properties of the SearchParams type, selecting only thosewhose type is
an array. The searchParamsArrayKeys constant is anobject that indicates
which parameters are expected to be arrays. Thisenhancement provides a
compile-time check for array parameters,improving type safety and code
readability.
This commit adds a new utility type, ConvertArrayToString, and a
function, combineAndFlattenArraySearchParams. The
ConvertArrayToStringtype transforms array properties of an object type
into stringproperties, leaving non-array properties unchanged.
ThecombineAndFlattenArraySearchParams function takes an object of
searchparameters, potentially containing array values, and returns a
newobject where array values are converted to comma-separated strings.
This is beneficial for preparing search parameters for API requestswhere
array parameters need to be serialized.
The handling of search parameters in the `search` method of
`SearchOnlyDocuments` has been refactored. The logic for combining and
flattening array search parameters has been moved to a utility function
`combineAndFlattenArraySearchParams` for better code reusability and
readability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant