mirror of
https://github.com/strapi/strapi.git
synced 2025-10-29 17:04:13 +00:00
Merge pull request #2911 from strapi/fix/users-count-role-sql
Fix user count per role on SQL database
This commit is contained in:
commit
0d731bf8cb
@ -11,9 +11,10 @@ module.exports = {
|
||||
.lean();
|
||||
},
|
||||
|
||||
count: async function (params = {}) {
|
||||
count: async function (params = {where: {}}) {
|
||||
return Number(await this
|
||||
.countDocuments(params));
|
||||
.countDocuments()
|
||||
.where(params.where));
|
||||
},
|
||||
|
||||
findOne: async function (params, populate) {
|
||||
|
||||
@ -182,7 +182,8 @@ module.exports = {
|
||||
|
||||
for (let i = 0; i < roles.length; ++i) {
|
||||
roles[i].id = roles[i].id || roles[i]._id;
|
||||
roles[i].nb_users = await strapi.query('user', 'users-permissions').count({ role: roles[i].id });
|
||||
|
||||
roles[i].nb_users = await strapi.query('user', 'users-permissions').count(strapi.utils.models.convertParams('user', { role: roles[i].id }));
|
||||
}
|
||||
|
||||
return roles;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user