#Select specific fields from nested doc

3 messages · Page 1 of 1 (latest)

lime onyx
#

We are fetching a doc and its children. The docs are quite large so we only want to select specific keys from the children docs. How can we modific the select in the REST API to also restrict the number of fields from the child?

Example:

We want to select the parent with id 1 but then ONLY the name from all its children, not the very_long_content. I cant seem to find a way to do this on the Rest api level.

Thanks for any pointers!

{
  "id": 1,
  "name": "parent_1",
  "children": [
    {
      "id": 1,
      "name": "child_1",
      "very_long_content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit..."
    },
    {
      "id": 2,
      "name": "child_2",
      "very_long_content": "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua..."
    },
    {
      "id": 3,
      "name": "child_3",
      "very_long_content": "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris..."
    }
  ]
}
lime onyx
#

For example, I cannot get it to work using the populate parameter:

  locale: 'en',
  depth: 1,
  'fallback-locale': 'en',
  select: { name: true, slug: true, id: true, children: true },
  populate: { children: { slug: true } }
}```

This simply returns all fields, even ignores my select. What am I doing wrong here?