Socket
Socket
Sign inDemoInstall

groq

Package Overview
Dependencies
Maintainers
57
Versions
869
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


Version published
Weekly downloads
243K
increased by17.09%
Maintainers
57
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 17 Sep 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