Admin plugin : listUsers total is not correct

Hi, When using list users the total returned do not take into account the filter clause. sample: auth.api.listUsers({ headers: await headers(), query: { filterField: "role", filterOperator: "eq", filterValue: "admin", limit: 1, }, }), You should have the total number of admin. As of today, we have the total of all users (admin and user role). Issue on github : https://github.com/better-auth/better-auth/issues/2108
GitHub
Admin plugin : listUsers total is not correct · Issue #2108 · be...
Is this suited for github? Yes, this is suited for github To Reproduce Hi, When using list users the total returned do not take into account the filter clause. sample: auth.api.listUsers({ headers:...
2 Replies
Netrifier
Netrifier3w ago
GitHub
fix(admin): Fix total in listUsers not using where clause by Netrif...
Fixed the total in admin.listUsers to return the correct total after using the where clause Changed internalAdapter.countTotalUsers function to accept an optional where clause Added test closes #2108
Netrifier
Netrifier3w ago
This pr relies on the count function of all db adapters to correctly filter based on the where clause. Mongodb and memory adapters currently does not filter count by where clause. Also the drizzle adapter has a bug where it returns res.count instead of res[0].count resulting in undefined being returned. I have fixed these in pr https://github.com/better-auth/better-auth/pull/1737
GitHub
feat: refactor database adapters by Netrifier · Pull Request #1737...
Drizzle Adapter: Refactored the convertWhereClause function to handle all operator conversions. Changed the order of parameters convertWhereClause(model: string, where?: Where[]) to make them cons...

Did you find this page helpful?