javascript - 如何定义 NOT 是 sanity.io 结构生成器?

标签 javascript sanity groq

我正在尝试过滤所有没有类别的产品(这是引用数组),但找不到具体操作方法。

S.listItem()
  .title('Without category')
  .id('productsWithoutCategories')
    .child(
      S.documentList()
        .title('Without categories')
        .menuItems(S.documentTypeList('product').getMenuItems())
        .filter('_type == $type && !category')
        .params({ type: 'product' })
      )

!category 不起作用。 我将不胜感激您的帮助。

最佳答案

用 Vision 找到答案(非常令人愉快的工具)

https://www.sanity.io/docs/the-vision-plugin

 .filter('_type == $type && !defined(categories)')
 .params({ type: 'product' })

关于javascript - 如何定义 NOT 是 sanity.io 结构生成器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60274079/

相关文章:

content-management-system - 无法在 Sanity CMS 中进行搜索查询

javascript - Sanity.io GROQ 查询中的随机排序不起作用?

javascript - 按卖家对一系列销售额进行分组,从每个卖家那里获取总数,按总销售额排序

sanity - 如何使用算术运算符计算总和

javascript - glDrawElements : Source and destination textures of the draw are the same

sanity - 如何将内部联接作为 GROQ 中的条件?

sanity - 如何获取所有文档中的最新文档

next.js - 理智 GROQ : How do i get drafts for the array of references in a document?

javascript - _gaq.push 无法正常工作吗?

javascript - 定义正则表达式