Re: Using JSONB with nested key-value structures, and skipping/wildcarding the key

2020-06-02 Thread Alban Hertroys
> On 2 Jun 2020, at 9:30, Shaheed Haque wrote: > > >> I do something like this to get a set of sub-paths in a JSONB field (no idea >> how to write that in Django): >> >> select snapshot->’pay_definition’->k.value->’name’ >> from MyModel >> join lateral jsonb_object_keys(snapshot->’pay_de

Re: Using JSONB with nested key-value structures, and skipping/wildcarding the key

2020-06-02 Thread Thomas Kellerer
> One question: as a novice here, I think I understand the right hand > side of your JOIN "... k(value)" is shorthand for: > > ... AS table_name(column_name) > > except that I don't see any clues in the docs that > jsonb_object_keys() is a "table function".> Can you kindly clarify? The clue is in

Re: Using JSONB with nested key-value structures, and skipping/wildcarding the key

2020-06-02 Thread Shaheed Haque
> > Hi, > > On Mon, 1 Jun 2020 at 23:50, Alban Hertroys wrote: > > On 1 Jun 2020, at 20:18, Shaheed Haque wrote: > > > > Hi, > > > > I'm using Django's ORM to access Postgres12. My "MyModel" table has a > JSONB column called 'snapshot'. In Python terms, each row's 'snapshot' > looks like this:

Re: Using JSONB with nested key-value structures, and skipping/wildcarding the key

2020-06-01 Thread Alban Hertroys
> On 1 Jun 2020, at 20:18, Shaheed Haque wrote: > > Hi, > > I'm using Django's ORM to access Postgres12. My "MyModel" table has a JSONB > column called 'snapshot'. In Python terms, each row's 'snapshot' looks like > this: > > == > snapshot = { > 'pay_definition' : {

Using JSONB with nested key-value structures, and skipping/wildcarding the key

2020-06-01 Thread Shaheed Haque
Hi, I'm using Django's ORM to access Postgres12. My "MyModel" table has a JSONB column called 'snapshot'. In Python terms, each row's 'snapshot' looks like this: == snapshot = { 'pay_definition' : { '1234': {..., 'name': 'foo', ...}, '99': {..., 'name': 'ba