如何在单个查询中填充引用数组

时间:2018-01-16 11:03:29

标签: sanity groq

我有一个模式类型Page,它有一个块数组:

{
  title: 'Page',
  name: 'page',
  type: 'document',
  fields: [
    ...
    {
      title: 'Blocks',
      name: 'blocks',
      type: 'array',
      of: [
        {type: 'tileGrid'},
        {type: 'otherType'}
      ],
      options: {
        editModal: 'fullscreen'
      }
    }
  ]
}

类型tileGrid包含以下字段:

{
      title: 'Tiles',
      name: 'tiles',
      type: 'array',
      of:  [{
        type: 'reference',
        to: [
          {type: 'tile'}
        ]
      }]
}

因此tile类型是深层嵌套的page.blocks[].tiles[].tile。 如何查询page并在同一查询中填写tile引用?

1 个答案:

答案 0 :(得分:2)

由于tile是引用,因此您需要解除引用运算符,而不是点运算符。这应该有效:page.blocks[].tiles[]->