Feature Request: json_extend, jsonb_extend

From: Kiswono Prayogo <kiswono(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Feature Request: json_extend, jsonb_extend
Date: 2014-12-17 13:59:16
Message-ID: CANiF8TQ9y5wP7MFYerptSk-P=w=0uaphKvdHRrBY4E7GQOJ_hA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

It would be nice if PostgreSQL has *_extend (similar to $.extend from
jQuery or _.extend from UnderscoreJs) for JSON/JSONB columns, so we could
write it like this:

UPDATE tablename
SET jsoncolumn = json_extend(jsoncolumn, $2)
WHERE id = $1;

instead of this:

UPDATE tablename
SET data = (
SELECT json_object_agg(key, value)::jsonb
FROM
( SELECT * FROM jsonb_each( SELECT data FROM tablename WHERE id=$1 )
UNION ALL
SELECT * FROM jsonb_each( $2 )
) x1
) WHERE id=$1;

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2014-12-17 14:20:54 Re: Storing Video's or vedio file in DB.
Previous Message Alban Hertroys 2014-12-17 13:22:36 Re: Storing Video's or vedio file in DB.