4

我在理智中有这样的内容块:

export default {
title: "Block Content",
name: "blockContent",
type: "array",
of: [
    /// stuff here
    {
        title: "Book",
        type: "reference",
        to: [{ type: "book" }],
    },
],
};

当进行类似的查询时

'*[_type == "post"]{...,body[]{..., asset->{..., "_key": _id}, markDefs[]{..., _type == "internaLink" => {"slug": @.reference->slug}}}';

我得到了参考,但我想返回完整的文档。我尝试了每种方法,但文档仅解释了内容块之外的引用,并且这些方法不起作用。

这是查询返回的内容:

  _createdAt: '2020-12-07T14:43:34Z',
  _id: '9d628aa6-aba7-4b53-aa9f-c6e97583baf9',
  _rev: 'ZZ0GkIKCRvD0tdMQPywPfl',
  _type: 'post',
  _updatedAt: '2020-12-07T14:43:34Z',
  body: [
    {
      _key: '4184df372bae',
      _type: 'block',
      children: [Array],
      markDefs: [],
      style: 'normal'
    },
    {
      _key: '56bed8835a7d',
      _ref: 'dc2eefee-2200-43e1-99c7-ea989dda16ba',
      _type: 'reference'
    }
  ],
  title: 'Example'
4

1 回答 1

0

解决了,我在这里写解决方案,因为我在网上一无所获。基本上我随机尝试任何东西,直到我得到想要的结果。查询是:

_type=="reference"=>^->
于 2020-12-07T15:54:33.107 回答