Re: JSONB filed with default JSON from a file

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: JSONB filed with default JSON from a file
Дата
Msg-id CAHyXU0zcM_S+7CtObiSEUr0W1COue6LcjSvDz4u7w-NPUexfjw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: JSONB filed with default JSON from a file  (mrcasa bengaluru <mrcasablr@gmail.com>)
Ответы Re: JSONB filed with default JSON from a file  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Mon, Aug 13, 2018 at 12:56 PM mrcasa bengaluru <mrcasablr@gmail.com> wrote:
>>
>> I assume that you could declare the column as
>>
>> address jsonb not null default 'your json here'::jsonb;
>
>
> Thanks! However, this involves writing the entire JSON in the schema file looks inconvenient. I was hoping I would be
ableto reference to an external JSON file which could be used for the default value.
 

1) Stick the default json in a table somewhere, say default_json with
one row, one column
2) Wrap the table with a function, default_json() that returns the
value from the table
3) Make a default function for the table, DEFAULT default_json().
That way you externalize the default into the database

merlin


В списке pgsql-general по дате отправления:

Предыдущее
От: mrcasa bengaluru
Дата:
Сообщение: Re: JSONB filed with default JSON from a file
Следующее
От: Tom Lane
Дата:
Сообщение: Re: JSONB filed with default JSON from a file