Comment

Comment by atombender

Correct me if I'm wrong — my use of Jq is limited to basic shell stuff — but I believe Jq does not have joins at all. You can do joining by writing your own functions, but it's not built into the syntax.

GROQ was designed to query and join multiple sources of data, and to make it easy to plan for efficient execution (e.g. on top of a relational database or search engine). For example:

    *[_type == "author"] {
      _id,
      name,
      "books": *[_type == "book" && author == ^._id] {
        title,
        year,
        publisher->  // Join referenced publisher
        genres[]->   // and all the genres
      ]
    }
This gives you all the authors with each author's books. You can do a lot of the same transformations that Jq does, but you can also do it across multiple collections of data; it's not a pipeline with an implicit input.

(Disclosure: I work at Sanity.)

parent atombender 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton