Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

groq

Package Overview
Dependencies
Maintainers
65
Versions
934
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

groq

Tagged template literal for Sanity.io GROQ-queries

  • 3.65.1-export-comments.7
  • export-comments
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
225K
increased by14.64%
Maintainers
65
Weekly downloads
 
Created

What is groq?

The groq npm package is a JavaScript implementation of GROQ (Graph-Relational Object Queries), a query language designed for querying JSON documents. It is particularly useful for querying data in headless CMS systems like Sanity.io.

What are groq's main functionalities?

Basic Querying

This feature allows you to perform basic queries on JSON documents. The example code demonstrates how to query all documents of type 'post'.

const groq = require('groq');
const query = groq`*[_type == 'post']`;
console.log(query);

Filtering

This feature allows you to filter documents based on specific conditions. The example code demonstrates how to query documents of type 'post' with the title 'Hello World'.

const groq = require('groq');
const query = groq`*[_type == 'post' && title == 'Hello World']`;
console.log(query);

Projection

This feature allows you to project specific fields from the documents. The example code demonstrates how to query documents of type 'post' and project only the 'title' and 'author' fields.

const groq = require('groq');
const query = groq`*[_type == 'post']{title, author}`;
console.log(query);

Ordering

This feature allows you to order the results of your query. The example code demonstrates how to query documents of type 'post' and order them by the 'publishedAt' field in descending order.

const groq = require('groq');
const query = groq`*[_type == 'post'] | order(publishedAt desc)`;
console.log(query);

Other packages similar to groq

Keywords

FAQs

Package last updated on 28 Nov 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc