Actions
dev #2960
openDescription
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
roleandisVerified. - Implemented multi-filtering support so filters can be combined (e.g., role + verification + search).
- Added filtering by
-
Query Shape
- Ensured that when custom
fieldsare requested, all necessary joined fields are included to avoid partial/undefined results.
- Ensured that when custom
-
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.
- Replaced raw SQL fragments with Drizzle utilities (
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