Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

510
Visualizações
Strapi v4: no relational fields when populating

I'm trying to populate a specific relation, using the relation name (categories) in combination with the populate parameter but it doesn't populate the categories.

When I look at my schema, I see that the relational field is present in the attributes object. But I still only get the non-relational fields in my response.

I tried every combination mentioned on the Strapi documentation but none of them worked.

The find permission is also enabled for the content-types that are being populated which in this case is categories.

/api/products?populate=*
/api/products?populate[0]=categories
/api/products?populate[categories]=*

My Product schema

{
  "kind": "collectionType",
  "collectionName": "products",
  "info": {
    "singularName": "product",
    "pluralName": "products",
    "displayName": "Product",
    "description": ""
  },
  "options": {
    "draftAndPublish": true
  },
  "pluginOptions": {},
  "attributes": {
    "title": {
      "type": "string"
    },
    "images": {
      "type": "media",
      "multiple": true,
      "required": false,
      "allowedTypes": [
        "images"
      ]
    },
    "categories": {
      "type": "relation",
      "relation": "oneToMany",
      "target": "api::category.category"
    }
  }
}

System

  • Strapi version: 4.1.8
  • NPM version: 8.3.2
  • Node.js version: 16.13.2
  • Database: MySQL
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

you will have to populate inside your controller, as in Strapi documentation

Query Engine API: Populating

strapi.db.query('api::article.article').findMany({
 populate: true,
});

Entity Service API: Populating

const entries = await strapi.entityService.findMany('api::article.article', {
  populate: '*',
});

REST API: Population & Field Selection

const qs = require('qs');
const query = qs.stringify({
  fields: ['title', 'body'],
}, {
  encodeValuesOnly: true,
});

If you want to populate everything just use populate: '*'

If you want to populate a relation or more use populate: [relationOne, relationTwo]

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda