0

**下面给出的代码是名为 home 的片段的架构字段,并且 home 有与其连接的片段,例如 _trip、_accomodation、_testimonial。这些连接的片段再次与其模式中的其他片段连接。因此使用检索主片段api/v1/home 连接件的内部连接显示为 id。

如何获取该 ID 的数据???**

 {
      name: '_trip',
      label: 'Spotlight Trips',
      limit:4,
      type: 'joinByArray',
      withType: 'trip',
    },
    {
      name: '_accommodation',
      label: 'Spotlight Accommodations',
      type: 'joinByArray',
      withType: 'accommodation',
      limit:2,
    },
    {
      name: '_testimonial',
      label: 'Testimonials',
      type: 'joinByArray',
      withType: 'testimonial'
    },

下面给出的 json 是检索数据的一部分。我想获取另一部分的住宿和旅行数据,但这里显示的是它的 id。

"_home-spotlight": [
        {
          "_id": "cki5owqrv008obgundta0x6rp",
          "published": true,
          "trash": false,
          "type": "home-spotlight",
          "title": "spotlightAbove",
          "tripIds": [
            "cki5oqi7r0063bgun81o6umqd"
          ],
          "accommodationIds": [
            "cki5owga1008mbgunlxweuera"
          ],
4

1 回答 1

0

目前,ApostropheCMS 无法通过 Rest API 从内部连接(即集合连接有另一个集合连接)中获取内容。目前,我们将只获取该集合的 ID。因此,alexbea 说,我们必须执行另一个额外的 API 调用来使用 ID 获取该集合。

那些不使用 Rest API 的人可以使用withJoins [https://docs.apostrophecms.org/reference/field-types/joinbyarray.html#settings] 获取这些集合。

于 2021-01-15T16:24:05.263 回答