mm-share-lib 0.0.25 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm-share-lib",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "description": "Share the generic service, entity, dto.",
5
5
  "author": "Mesa SOT",
6
6
  "license": "MIT",
@@ -103,15 +103,17 @@ export abstract class ClientService<
103
103
  searchParameters: SearchParams,
104
104
  options: SearchOptions,
105
105
  ) => {
106
- searchParameters.per_page = searchParameters.per_page ?? 250;
106
+ const per_page = searchParameters.per_page ?? 250;
107
+ searchParameters.per_page = per_page;
107
108
  options.cacheSearchResultsForSeconds = 1;
108
109
  const response = await this.searchDocument(searchParameters, options);
109
110
  const { hits = [], found = 0, page = 1 } = { ...response };
110
- let documents = hits;
111
- const hasNext = hits?.length * page < found;
111
+ const documents = hits;
112
+ const hasNext = per_page * page < found;
112
113
  if (hasNext) {
113
114
  searchParameters.page = page + 1;
114
- documents = await this.getAllRawDocs(searchParameters, options);
115
+ const nextDocuments = await this.getAllRawDocs(searchParameters, options);
116
+ documents.push(...nextDocuments);
115
117
  }
116
118
  return documents;
117
119
  };