How can I find only products created by user

Preformatted text``Preformatted text[details=“System Information”]

  • Strapi Version: V4
  • Operating System: Linux
  • Database: MySQL
  • Node Version: 16.14.2
  • NPM Version: 8.7.0
  • Yarn Version:

I modified the controller, but I don’t know how can I select some product in DB by “created_by_id”. I’m trying something like this:

module.exports = createCoreController(‘api::produto.produto’, ({ strapi }) => ({
async findOne(ctx) {
const { user } = ctx.state;
const { id } = ctx.params;
const { query } = ctx;

    const entity = await strapi.service('api::produto.produto').findOne({
           id, query,
           where: {


but this format is not possible… someone got it?


Could you get it?

You can find the answer from my strapi study case.
You also can use findMany and filters, and you will find more solution from strapi docs


Hi @LuisAlaguna ! Not yet

You are using “filters”, but filters only can be used in find, not in findOne for example. I need to put something like a middleware. Example: GavinXue only can modify products created by him, so in the request, I need verify if the user_id is the same of created_by_id.

But you can use filter with findOne.

You can use db query API findOne as LuisAlaguna mentioned before. If you want use EntityService api, you can get the population result, then estimate the equation between query user and created user.

Sorry by the image, but new users can post only 1 picture.

This topic can be closed!
I found here: Get userinfo from createdBy and updatedBy v4 - #4 by Leonardo_Assef the solution! Thanks.