Socket
Socket
Sign inDemoInstall

sanity-groq-filter

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sanity-groq-filter

Curated List of GROQ Filters.


Version published
Maintainers
1
Created

Readme

Source

Sanity GROQ Filter

Curated List of GROQ Filters.

Usage / Examples

Removes all references which are already present in the parent and returns only the unused references.

unusedReferences-Filter

import GroqFilter from "sanity-groq-filter"

export default {
    name: 'documentName',
    type: 'document',
    fields: [
        {
            name: 'fieldName',
            type: 'array',
            of: [
                {
                    type: 'reference',
                    to: { type: 'someReferencedType' },
                    options: { filter: GroqFilter.unusedReferences }
                }
            ],
            validation: Rule => Rule.unique()
        },
    ]
}

matches-Filter

Filters to include only documents with ${fieldName} containing the ${matchStr}.

import GroqFilter from "sanity-groq-filter"

export default {
    name: 'documentName',
    type: 'document',
    fields: [
        {
            name: 'fieldName',
            type: 'array',
            of: [
                {
                    type: 'reference',
                    to: { type: 'someReferencedType' },
                    options: { filter: GroqFilter.matches('myField', 'barbeque') }
                }
            ],
            validation: Rule => Rule.unique()
        },
    ]
}

excludes-Filter

Filters to exclude documents with ${fieldName} containing the ${matchStr}.

import GroqFilter from "sanity-groq-filter"
//...
                    options: { filter: GroqFilter.excludes('myField', 'barbeque') }
//...

Further Reading

Sanity documentation on filters

Keywords

FAQs

Last updated on 12 Jun 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc