How can I filter data through a field of populate?

System Information
  • Strapi v: 4.0.2:
  • OS: Windows 11:
  • DataBase: Posgress:
  • Nodejs14.15.4:
  • Yarn: 1.22.10:

Hello, I am trying to make an order filter, I have a relationship of orders and seller. something like that :


{
        "id": 1,
        "orden": [
            {
                "id": "DHI23",
                "cantidad": "56",
                "producto": "DIAMOND HI ENERGY 23 KGS",
                "valorNeto": 31500
            }
        ],
        "fecha": "2021-12-30",
        "status": "esperando",
        "revisado_por_vendedor": true,
        "createdAt": "2021-12-25T13:15:10.244Z",
        "updatedAt": "2021-12-25T13:15:10.244Z",
        "vendedor": {
            "id": 1,
            "username": "Ramon",
            "email": "ramon@admin.cl",
            ...
        }
    }

I want to filter the current seller’s orders. but I can’t make it only return the orders by the seller’s id. and the answer that I get according to the code I have is this

const dataOrder = await strapi.entityService.findMany('api::order.order', 

      populate: {

        vendedor: {

          filters: {

            id: ctx.state.user.id

          }

        }

      }

    })

When the id does not correspond, it sends the sample as null, but it still brings me the orders. How can I check to bring the orders by the seller’s id?

try to access the id value. but it generates an error

const dataOrder = await strapi.entityService.findMany('api::order.order', {

      filters: {

        "vendedor.id": ctx.state.user.id

      },

      populate: {

        vendedor: {

          filters: {

            id: ctx.state.user.id

          }

        }

      }

    })

Is there any answer?

Did you find how to solve it?