Re: Context lenses to set/get values in json values.

From: Thom Brown <thom(at)linux(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Paweł Cesar Sanjuan Szklarz <paweld2(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Context lenses to set/get values in json values.
Date: 2014-10-08 18:04:27
Message-ID: CAA-aLv7nj14_omCCaEJ81Tv2xqycenSgoDDp8eoiWwQoTOmgug@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 8 October 2014 18:39, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
>
> On 10/08/2014 12:13 PM, Paweł Cesar Sanjuan Szklarz wrote:
>>
>>
>>
>>
>> I don't think we need to import Mongo type notation here. But
>> there is probably a good case for some functions like:
>>
>> json_table_agg(anyrecord) -> json
>>
>> which would work like json_agg() but would return an array of
>> arrays instead of an array of objects. The caller would be assumed
>> to know which field is which in the array. That should take care
>> of both the table_to_json and query_to_json suggestions above.
>>
>> In the other direction, we could have something like:
>>
>> json_populate_recordset_from_table(base anyrecord, fields
>> text[], jsontable json) -> setof record
>>
>> where jsontable is an array of arrays of values and fields is a
>> corresponding array of field names.
>>
>> I'm not sure how mainstream any of this is. Maybe an extension
>> would be more appropriate?
>>
>>
>>
>>
>> Hello.
>>
>> My personal interest is to send updates to a single json value in the
>> server. Which is the best way to make a update to a json value in postgres
>> without a full update of the already stored value?? the -> operator extract
>> a internal value, but to update the value I don't see any operator.
>>
>> I was not familiar with the extensions, but it looks like the best way to
>> start is to create a extension with possible implementations of new
>> functions. I will do so.
>>
>> In my project I considered to use mongo, but in my case the core part of
>> the model match perfectly a relational schema. I have some leaf concepts
>> that will change frequently, and to avoid migrations I store that
>> information in a json value. To make changes in such leaf values I would
>> like to have a "context lenses like api" in the server. I will start with
>> some toy extension and try to feel if this make sense.
>>
>>
>
> There is work already being done on providing update operations.

I've been looking out for that. Has there been a discussion on how
that would look yet that you could point me to?

--
Thom

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2014-10-08 18:47:57 Re: pg_dump refactor patch to remove global variables
Previous Message Andres Freund 2014-10-08 18:04:19 Re: Wait free LW_SHARED acquisition - v0.2