System Information
- Strapi Version: 4.2.3
- Operating System: Mac OS 12.4
- Database: mysql
- Node Version: 16.13.0
- NPM Version: 8.1.0
- Yarn Version: 1.22.19
I am using the strapi entityService to add more filter to my query. They are based on some user details.
Everything works as expected but unfortunately the meta object remains empty. There are no information about pagination available.
Is this the desired outcome? Is there anything missing in my controller’s code?
controller find method
async find(ctx) {
const userId = ctx.state.user.id
const { query } = ctx;
var queryCopy = { ...query }
queryCopy.start = query.pagination.page
queryCopy.limit = query.pagination.pageSize
queryCopy.filters.standort = {}
queryCopy.filters.standort.id = {}
queryCopy.filters.standort.id.$eq = 1;
const entity = await strapi.entityService.findMany('api::fahrzeug.fahrzeug', queryCopy);
const sanitizedEntity = await this.sanitizeOutput(entity, ctx);
return this.transformResponse(sanitizedEntity);
}
response
{"data":[{"id":848,"attributes":{"name":"9UKE2K5H","VIN":"IB4YNHOMY6BS3QQMG","damage":true,"createdAt":"2022-05-30T08:10:19.391Z","updatedAt":"2022-06-23T08:15:26.825Z","eigennutz":false,"nutzungsverhaeltnis":"Eltern","leasingType":"MAM","neuwagen":null,"qrcode":null,"kennzeichen":null,"kilometerstand":null}},{"id":855,"attributes":{"name":"QV1QVV5W","VIN":"Q3ZKMGOLO3J364CFB","damage":true,"createdAt":"2022-05-30T08:10:22.586Z","updatedAt":"2022-06-28T13:19:35.691Z","eigennutz":false,"nutzungsverhaeltnis":"Eltern","leasingType":"MAM","neuwagen":null,"qrcode":null,"kennzeichen":null,"kilometerstand":null}},{"id":857,"attributes":{"name":"D0BOA56W","VIN":"XXV3LOL1PX64NTM01","damage":true,"createdAt":"2022-05-30T08:10:22.990Z","updatedAt":"2022-06-23T08:15:27.103Z","eigennutz":false,"nutzungsverhaeltnis":"Geschwister","leasingType":"DW","neuwagen":null,"qrcode":null,"kennzeichen":null,"kilometerstand":null}}],"meta":{}}
How can I generate the normal api output with the included pagination object?
Thanks for your help.
Regards,
Philipps