Skip to main content
Version: v2.x

Postgres: Filter Using JSONB Objects

Introduction

The _contains, _contained_in, _has_key, _has_keys_any and _has_keys_all operators are used to filter based on JSONB columns.

For more details on JSONB operators and Postgres equivalents, refer to the API reference.

_contains

Fetch all authors living within a particular pincode (present in address JSONB column):

GraphiQL
Query Variables
Request Headers
Documentation Explorer
No Schema Available

_contained_in

This example fetches all items where the "Tags" property contains the value "tag1" and is also contained in the list ["tag1", "tag2"].

GraphiQL
Query Variables
Request Headers
Documentation Explorer
No Schema Available

_has_key

Fetch authors if the phone key is present in their JSONB address column:

GraphiQL
Query Variables
Request Headers
Documentation Explorer
No Schema Available

_has_keys_any

Fetch users who have either "admin" or "editor" permissions:

GraphiQL
Query Variables
Request Headers
Documentation Explorer
No Schema Available

_has_keys_all

Fetch user, where their id is "123", and check if the address has all the fields "street", "city", "state", "zip":

GraphiQL
Query Variables
Request Headers
Documentation Explorer
No Schema Available