Merge pull request #2911 from strapi/fix/users-count-role-sql

Fix user count per role on SQL database
This commit is contained in:
Jim LAURIE 2019-03-02 13:49:01 +01:00 committed by GitHub
commit 0d731bf8cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -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) {

View File

@ -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;