0

我有一个对象,它有一个名为tags. 它是对象数组。我需要查询那些tags包含不区分大小写字符串的对象。

[
  {
    "_createdAt": "2022-02-18T09:16:27Z",
    "_id": "article-13000018493",
    "_rev": "LRHtyYM9ePAzIgMqDbhEWY",
    "_type": "article",
    "_updatedAt": "2022-02-23T14:29:00Z",
    "slug": {
      "current": "learn-to-kode"
    },
    "tags": [
      {
        "value": "Java"
      },
      {
        "value": "Python"
      },
      {
        "value": "JS and ts"
      },
      {
        "value": "React"
      }
    ],
    "tittel": "Learn to code"
  },
  {
    "_createdAt": "2022-02-18T09:16:27Z",
    "_id": "article-352398563",
    "_rev": "LRHtyYM9ePAzIgMqDbhEWY",
    "_type": "article",
    "_updatedAt": "2022-02-23T14:29:00Z",
    "slug": {
      "current": "learn-to-kode-js"
    },
    "tags": [
      {
        "value": "React"
      },
      {
        "value": "Next.js"
      },
      {
        "value": "js and TS"
      },
      {
        "value": "Vue"
      }
    ],
    "tittel": "Learn to code JS"
  }
]

我用过这个查询

*[_type == 'articles' &&  'js and TS' in tags[].value] {
  ...,
  tags[] { value }
}

它只返回最后一个对象,因为第一个对象的标签包含JS and ts,而不是js and TS

如果标签包含不区分大小写的参数,如何获取这两个对象?

这是我在 groq.dev 上的查询链接。

https://groq.dev/P6RknxgQtDXJPG8UFJ6WyS

4

0 回答 0