@adobe/spacecat-shared-data-access 2.12.0 → 2.13.0
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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/models/base/base.collection.js +17 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-data-access-v2.13.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.12.0...@adobe/spacecat-shared-data-access-v2.13.0) (2025-03-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **data-access:** fetch all records on demand ([#659](https://github.com/adobe/spacecat-shared/issues/659)) ([a424f47](https://github.com/adobe/spacecat-shared/commit/a424f4763399ceaa1fb2d09bee454e8d5d0923f9))
|
|
7
|
+
|
|
1
8
|
# [@adobe/spacecat-shared-data-access-v2.12.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.11.0...@adobe/spacecat-shared-data-access-v2.12.0) (2025-03-06)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -248,15 +248,26 @@ class BaseCollection {
|
|
|
248
248
|
);
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
|
|
251
|
+
// execute the initial query
|
|
252
|
+
let result = await query.go(queryOptions);
|
|
253
|
+
let allData = result.data;
|
|
254
|
+
|
|
255
|
+
// if the caller requests ALL pages and we're not using limit: 1,
|
|
256
|
+
// continue to fetch until there is no LastEvaluatedKey.
|
|
257
|
+
if (options.fetchAllPages && options.limit !== 1) {
|
|
258
|
+
while (result.lastEvaluatedKey) {
|
|
259
|
+
// update queryOptions with the start key to fetch the next page
|
|
260
|
+
queryOptions.ExclusiveStartKey = result.lastEvaluatedKey;
|
|
261
|
+
// eslint-disable-next-line no-await-in-loop
|
|
262
|
+
result = await query.go(queryOptions);
|
|
263
|
+
allData = allData.concat(result.data);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
252
266
|
|
|
253
267
|
if (options.limit === 1) {
|
|
254
|
-
|
|
255
|
-
return null;
|
|
256
|
-
}
|
|
257
|
-
return this.#createInstance(records.data[0]);
|
|
268
|
+
return allData.length ? this.#createInstance(allData[0]) : null;
|
|
258
269
|
} else {
|
|
259
|
-
return this.#createInstances(
|
|
270
|
+
return this.#createInstances(allData);
|
|
260
271
|
}
|
|
261
272
|
} catch (error) {
|
|
262
273
|
return this.#logAndThrowError('Failed to query', error);
|