question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

deep filtering json/jsonb data

See original GitHub issue

https://docs.hasura.io/1.0/graphql/manual/api-reference/graphql-api/query.html#simple-object

The documentation seems to missing information or I am going about it the wrong way… probably the later 😃

I have a table with “id” and “data” being jsonb.

I cant see how to query for “order_id”

{
  tasks(where: {data: { ? }}) { // "order_id" _eq: 123456
    data
  }
}

Also how do I return all the task names?

Is it also necessary to do data(path: "") for every single field I want? Seems rather repetitive.

{
  tasks {
    order_id: data(path: "order_id")
    tasks_names: data(path: "tasks.name") // fails NULL
    tasks_names1: data(path: "tasks[*].name") // fails
  }
}

Below is the data structure.

{
  "data": {
    "tasks": [
      {
        "data": {
          "owner": "me",
          "tasks": [
            {
              "name": "task 1",
              "actioned": "yes"
            },
            {
              "name": "task 2",
              "actioned": "no"
            },
            {
              "name": "task 3",
              "actioned": "yes"
            }
          ],
          "order_id": 123456
        }
      },
      {
        "data": {
          "owner": "me",
          "tasks": [
            {
              "name": "task 1",
              "actioned": "no"
            },
            {
              "name": "task 2",
              "actioned": "no"
            },
            {
              "name": "task 3",
              "actioned": "no"
            }
          ],
          "order_id": 654321
        }
      }
    ]
  }
}

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:7
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

18reactions
webdebcommented, Oct 7, 2020

postgres 12 added jsonpath, which gives postgres solid NoSQL capabilities. You can even index the json like a boss: for example "rooms.*.id" “JSON/B” is a first-class citizen in Postgres now.

Adding support for “jsonpath” as a filter option would be great!

15reactions
JohnRock0422commented, May 25, 2022

Any plan in roadmap about support json path in query?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Querying JSON (JSONB) data types in PostgreSQL
These operators work on both JSON as well as JSONB columns. Because the -> operator returns an object, you can chain it to...
Read more >
Faster Operations with the JSONB Data Type in PostgreSQL
Lucero Del Alba takes a look at how to get better performance out of jsonb data types in PostgreSQL in this Compose's Write...
Read more >
Javascript implement deep filtering in nested json data
I look at lodash but it does not seem to have a deep filter. I am now thinking about using a tree traversal...
Read more >
Deep Filtering: Signal Extraction and Reconstruction Using ...
Signal extraction from a single-channel mixture with additional undesired signals is most commonly performed using time-frequency (TF) masks.
Read more >
How to Filter Results on Deeply Nested fields in Strapi
Learn about different ways to deeply filter results using ... Some dummy data will help us explore different approaches in a practice way....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found