@7365admin1/core 3.47.1-staging.126 → 3.47.1-staging.127
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/.changeset/members-paging-skip.md +18 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/member-paging.test.mjs +93 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@7365admin1/core": patch
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Fix GET /api/members returning the same page over and over
|
|
6
|
+
|
|
7
|
+
`member.repo.ts` `getAll` built its aggregate with `{ $limit: limit }` and no
|
|
8
|
+
`$skip`. `paginate()` only *labels* the range — it returns `items` untouched and
|
|
9
|
+
computes `pageRange` arithmetically — so the server answered page 2 with page
|
|
10
|
+
1's rows under an "11-20 of 42" heading. Every Members screen in every app was
|
|
11
|
+
affected, not one screen.
|
|
12
|
+
|
|
13
|
+
`{ $skip: page * limit }` is added ahead of the limit, matching the two
|
|
14
|
+
`getOrgs*` reads in the same file that were already correct. `page` is
|
|
15
|
+
zero-based by then, and the cache key already varies by page, so no cache
|
|
16
|
+
change is needed.
|
|
17
|
+
|
|
18
|
+
The response shape is unchanged: `{ items, pages, pageRange }`.
|
package/dist/index.js
CHANGED
|
@@ -9976,6 +9976,11 @@ function useMemberRepo() {
|
|
|
9976
9976
|
const items = await collection.aggregate([
|
|
9977
9977
|
{ $match: query2 },
|
|
9978
9978
|
{ $sort: { _id: -1 } },
|
|
9979
|
+
// `paginate()` only LABELS the range ("11-20 of 42"); it does not
|
|
9980
|
+
// slice. Without this $skip every page returned page 1's rows under
|
|
9981
|
+
// a later page's heading. `page` is already zero-based above, and
|
|
9982
|
+
// this is the same $skip/$limit pair the two getOrgs* reads use.
|
|
9983
|
+
{ $skip: page * limit },
|
|
9979
9984
|
{ $limit: limit },
|
|
9980
9985
|
{
|
|
9981
9986
|
$lookup: {
|