Making use of JSONPATH

JSONPATH is also one of those features that are highly relevant to developers. Many people have asked for this functionality in the past and PostgreSQL 12 finally provides the desired capability.

Here are some examples:

test=# SELECT jsonb_path_exists('{"a": 1}', '$.a');
jsonb_path_exists
-------------------
t
(1 row)

test=# SELECT '{"a": 1}'::jsonb @? '$.a';
?column?
----------
t
(1 row)

test=# SELECT jsonb_path_match('{"a": 1}', '$.a == 1');
jsonb_path_match
------------------
t
(1 row)

test=# SELECT '{"a": 1}'::jsonb @@ '$.a == 1';
?column?
----------
t
(1 row)

As you can see, a couple of new functions have been added to dissect a JSON document quickly and easily. This will greatly boost PostgreSQL 12's ability to handle NoSQL-style workloads.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset