use findAll instead of find

Signed-off-by: Pierre Noël <petersg83@gmail.com>
This commit is contained in:
Pierre Noël 2020-05-19 15:40:04 +02:00 committed by Alexandre Bodin
parent f9df191157
commit 407949a70a
4 changed files with 14 additions and 5 deletions

View File

@ -172,7 +172,7 @@
{
"method": "GET",
"path": "/roles",
"handler": "role.find",
"handler": "role.findAll",
"config": {
"policies": []
}

View File

@ -13,8 +13,8 @@ module.exports = {
data: role,
};
},
async find(ctx) {
const roles = await strapi.admin.services.role.find({ _limit: -1 });
async findAll(ctx) {
const roles = await strapi.admin.services.role.findAll();
ctx.body = {
data: roles,
};

View File

@ -52,9 +52,9 @@ describe('Role', () => {
query: () => ({ find: dbFind }),
};
const foundRoles = await roleService.find();
const foundRoles = await roleService.findAll();
expect(dbFind).toHaveBeenCalledWith({});
expect(dbFind).toHaveBeenCalledWith({ _limit: -1 });
expect(foundRoles).toStrictEqual(roles);
});
});

View File

@ -25,8 +25,17 @@ const find = (params = {}) => {
return strapi.query('role', 'admin').find(params);
};
/**
* Find all roles in database
* @returns {Promise<array>}
*/
const findAll = () => {
return strapi.query('role', 'admin').find({ _limit: -1 });
};
module.exports = {
create,
findOne,
find,
findAll,
};