mirror of
https://github.com/strapi/strapi.git
synced 2025-12-28 07:33:17 +00:00
use findAll instead of find
Signed-off-by: Pierre Noël <petersg83@gmail.com>
This commit is contained in:
parent
f9df191157
commit
407949a70a
@ -172,7 +172,7 @@
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/roles",
|
||||
"handler": "role.find",
|
||||
"handler": "role.findAll",
|
||||
"config": {
|
||||
"policies": []
|
||||
}
|
||||
|
||||
@ -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,
|
||||
};
|
||||
|
||||
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
@ -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,
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user