Hi @Eventyret,
I think that this confusion between strapi.service and strapi.entityService (me also → What is the difference between strapi.service() and strapi.entityService()) is caused by the documentation. In fact in the controllers section when you looking for a replacing of a core action, the documentation refers to strapi.service.
// Method 3: Replacing a core action
async findOne(ctx) {
const { id } = ctx.params;
const { query } = ctx;
const entity = await strapi.service('api::restaurant.restaurant').findOne(id, query);
const sanitizedEntity = await this.sanitizeOutput(entity, ctx);
return this.transformResponse(sanitizedEntity);
}
furthermore there is no documentation about transformResponse and sanitizeOutput (or sanitizeInput) so this generate a big confusion.
For what i understood there are 4 method to build a new controller.
super
when you want to use an unique function with sanitize and transform functions included (with also meta object)
strapi.service
with no documentation (only an example in the backend customization section) that seems to be a entityService API with some more date like meta object
strapi.entityService
that is the documented API that
is the layer that handles strapi’s complex data structures
but when you want to expose it to the front-end (if you want to keep the structure with data-attributes) you have to sanitize (??) and transform the response before to expose it.
strapi.db.connection
that is a lower level of entityService.
I’m right?