在内容中搜索多个参考字段

问题描述 投票:1回答:1

我试图找出如何根据作者(参考)来检索特定文章,我当前的函数检索所有文章,但我只希望作者特定的文章

 const resp = yield client.getEntries({
  'fields.insightsArticle': true,
  'fields.excludeCountries[nin]': country,
  'fields.publicationDate[lte]': moment(new Date()).toISOString(),
  'fields.author.fields.firstname': author.firstName,
  'fields.author.fields.lastname': author.lastName,
  content_type: 'insight',
  include: 2,
  order: '-fields.publicationDate',
  limit,
  locale,
});

我从内容查询中获得的当前日志是:“在搜索引用时,必须指定引用的内容类型。请发送内容类型id作为查询参数”

我知道了,因为我将内容类型定义为洞察力。

欢迎提出任何建议!

javascript contentful
1个回答
0
投票

我有同样的问题!您可以通过添加以下内容来指定引用的内容类型:

'fields.author.sys.contentType.sys.id': 'author'

此外,由于您不使用这些字段,因此我会将content_type:'insight'行作为第一个条目并删除限制和语言环境。

© www.soinside.com 2019 - 2024. All rights reserved.