@adobe/spacecat-shared-data-access 2.12.0 → 2.13.1
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 +14 -0
- package/package.json +1 -1
- package/src/models/base/base.collection.js +16 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-data-access-v2.13.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.13.0...@adobe/spacecat-shared-data-access-v2.13.1) (2025-03-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **data-access:** fetch all records on demand ([#660](https://github.com/adobe/spacecat-shared/issues/660)) ([16bbeb4](https://github.com/adobe/spacecat-shared/commit/16bbeb4767526c846800480f49e2f7d06912330f))
|
|
7
|
+
|
|
8
|
+
# [@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)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **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))
|
|
14
|
+
|
|
1
15
|
# [@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
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -248,15 +248,25 @@ 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 cursor.
|
|
257
|
+
if (options.fetchAllPages && options.limit !== 1) {
|
|
258
|
+
while (result.cursor) {
|
|
259
|
+
queryOptions.cursor = result.cursor;
|
|
260
|
+
// eslint-disable-next-line no-await-in-loop
|
|
261
|
+
result = await query.go(queryOptions);
|
|
262
|
+
allData = allData.concat(result.data);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
252
265
|
|
|
253
266
|
if (options.limit === 1) {
|
|
254
|
-
|
|
255
|
-
return null;
|
|
256
|
-
}
|
|
257
|
-
return this.#createInstance(records.data[0]);
|
|
267
|
+
return allData.length ? this.#createInstance(allData[0]) : null;
|
|
258
268
|
} else {
|
|
259
|
-
return this.#createInstances(
|
|
269
|
+
return this.#createInstances(allData);
|
|
260
270
|
}
|
|
261
271
|
} catch (error) {
|
|
262
272
|
return this.#logAndThrowError('Failed to query', error);
|