Project

General

Profile

Actions

dev #2960

open

dev #2956: [Module] Sprint 13

dev #2959: [BE] Admin Dashboard apis

[BE] User listing api

Added by Zahid Hassan 8 months ago. Updated 8 months ago.

Status:
In Progress
Priority:
High
Assignee:
Target version:
Start date:
08/21/2025
Due date:
% Done:

100%

Estimated time:
4:00 h
Spent time:

Description

Summary

This enhances the user listing endpoint with robust filtering and query improvements. It introduces role-based and verification-based filters, supports combining multiple filters, aligns the count query with the same filtering logic, and completes the selected-fields projection. It also replaces raw SQL predicates with Drizzle’s helpers for safer, clearer queries.

Changes

  • Filtering
    • Added filtering by role and isVerified.
    • Implemented multi-filtering support so filters can be combined (e.g., role + verification + search).
  • Query Shape
    • Ensured that when custom fields are requested, all necessary joined fields are included to avoid partial/undefined results.
  • Count Query
    • Updated count logic to mirror the same filters as the data query for accurate pagination totals.
  • Implementation
    • Replaced raw SQL fragments with Drizzle utilities (and, eq, ilike, desc) for better parameter binding and readability.

Example Usage

Query Parameters

{
   "search": "development",
   "fields": "id,userName,profileImage,isVerified,createdAt,roleId"
   "role": "admin",   // admin/user/owner
   "isVerified": "true",   // true/false
   "sort": "desc"   // desc/asc
}

Expected Response

{
    "success": true,
    "data": [
        {
            "id": 1,
            "userName": "development",
            "profileImage": "https://cdn.onlinegradecalculator.io/aiaxio-images/development-team.png",
            "isVerified": true,
            "createdAt": "2025-08-07T07:15:53.454Z",
            "roleId": 1
        }
    ],
    "pagination": {
        "offset": 0,
        "limit": 10,
        "total": 1,
        "currentCount": 1
    },
    "_links": {
        "self": {
            "href": "http://localhost:8000/api/user-management/users?offset=0&limit=10&search=development"
        },
        "next": null,
        "previous": null,
        "collection": {
            "href": "http://localhost:8000/api/user-management/users"
        }
    }
}
Actions

Also available in: Atom PDF