Skip to content
This repository was archived by the owner on Apr 19, 2023. It is now read-only.

Commit 23144aa

Browse files
✨ Make pagination work for members
1 parent 438343d commit 23144aa

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/controllers/organization.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ export class OrganizationController {
300300
await getOrganizationMembershipsForUser(
301301
res.locals.token.id,
302302
organizationId,
303-
req.params.start
303+
req.query.start
304304
)
305305
);
306306
}

src/crud/data.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,19 @@ export const getPaginatedData = async (
2121
} ORDER BY ${primaryKey} ASC LIMIT ${itemsPerPage}`,
2222
[index, ...(conditions ? Object.values(conditions) : [])]
2323
)) as any[];
24+
console.log(
25+
`SELECT * FROM \`${table}\` WHERE ${primaryKey} > ? ${
26+
conditions
27+
? `AND ${Object.keys(conditions)
28+
.map(condition => `${condition} = ?`)
29+
.join(" AND ")}`
30+
: ""
31+
} ORDER BY ${primaryKey} ASC LIMIT ${itemsPerPage}`,
32+
[index, ...(conditions ? Object.values(conditions) : [])]
33+
);
2434
return {
2535
data,
26-
has_more: data.length === itemsPerPage,
36+
hasMore: data.length === itemsPerPage,
2737
next: data.length && data[data.length - 1][primaryKey]
2838
};
2939
};

src/crud/membership.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export const getOrganizationMemberDetails = async (
176176
{ organizationId },
177177
start
178178
);
179-
for await (const member of members) {
179+
for await (const member of members.data) {
180180
member.user = await getUser(member.userId);
181181
}
182182
return members;

0 commit comments

Comments
 (0)