mirror of
https://github.com/strapi/strapi.git
synced 2026-01-08 05:04:10 +00:00
Move ML find many to find page
This commit is contained in:
parent
fdc0fa82fc
commit
7676bf8890
@ -37,7 +37,7 @@ module.exports = {
|
||||
|
||||
const query = pm.addPermissionsQueryTo(ctx.query);
|
||||
|
||||
const files = await getService('upload').fetchAll(query);
|
||||
const files = await getService('upload').findPage(query);
|
||||
|
||||
ctx.body = pm.sanitize(files, { withPrivate: false });
|
||||
},
|
||||
|
||||
@ -15,7 +15,7 @@ const sanitize = (data, options = {}) => {
|
||||
|
||||
module.exports = {
|
||||
async find(ctx) {
|
||||
const files = await getService('upload').fetchAll(ctx.query);
|
||||
const files = await getService('upload').findMany(ctx.query);
|
||||
|
||||
ctx.body = sanitize(files);
|
||||
},
|
||||
|
||||
@ -302,10 +302,14 @@ module.exports = ({ strapi }) => ({
|
||||
return strapi.entityService.findOne('plugin::upload.file', id, { populate });
|
||||
},
|
||||
|
||||
fetchAll(query) {
|
||||
findMany(query) {
|
||||
return strapi.entityService.findMany('plugin::upload.file', query);
|
||||
},
|
||||
|
||||
findPage(query) {
|
||||
return strapi.entityService.findPage('plugin::upload.file', query);
|
||||
},
|
||||
|
||||
count(query) {
|
||||
return strapi.entityService.count('plugin::upload.file', query);
|
||||
},
|
||||
|
||||
@ -142,7 +142,26 @@ describe('Upload plugin end to end tests', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test.todo('GET /upload/files => Find files');
|
||||
test('GET /upload/files => Find files', async () => {
|
||||
const getRes = await rq({ method: 'GET', url: '/upload/files' });
|
||||
|
||||
expect(getRes.statusCode).toBe(200);
|
||||
expect(getRes.body).toEqual({
|
||||
results: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: expect.anything(),
|
||||
url: expect.any(String),
|
||||
}),
|
||||
]),
|
||||
pagination: {
|
||||
page: expect.any(Number),
|
||||
pageSize: expect.any(Number),
|
||||
pageCount: expect.any(Number),
|
||||
total: expect.any(Number),
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test.todo('GET /upload/files/count => Count available files');
|
||||
test.todo('GET /upload/files/:id => Find one file');
|
||||
test.todo('GET /upload/search/:id => Search files');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user