mirror of
https://github.com/docmost/docmost.git
synced 2025-11-15 20:01:12 +10:00
Implement space member search (#731)
* Hide pagination buttons if there is nothing to paginate * Create reusable hook for search and pagination
This commit is contained in:
@ -97,7 +97,7 @@ export class SpaceMemberRepo {
|
||||
spaceId: string,
|
||||
pagination: PaginationOptions,
|
||||
) {
|
||||
const query = this.db
|
||||
let query = this.db
|
||||
.selectFrom('spaceMembers')
|
||||
.leftJoin('users', 'users.id', 'spaceMembers.userId')
|
||||
.leftJoin('groups', 'groups.id', 'spaceMembers.groupId')
|
||||
@ -116,6 +116,16 @@ export class SpaceMemberRepo {
|
||||
.where('spaceId', '=', spaceId)
|
||||
.orderBy('spaceMembers.createdAt', 'asc');
|
||||
|
||||
if (pagination.query) {
|
||||
query = query.where((eb) =>
|
||||
eb('users.name', 'ilike', `%${pagination.query}%`).or(
|
||||
'groups.name',
|
||||
'ilike',
|
||||
`%${pagination.query}%`,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
const result = await executeWithPagination(query, {
|
||||
page: pagination.page,
|
||||
perPage: pagination.limit,
|
||||
|
||||
Reference in New Issue
Block a user