Я пытаюсь добавить элемент JSON к уже существующему массиву в моей базе данных. Я знаю о jsonb_set, однако я не могу перейти на Postgres 9.4, так как это отличный проект, а последняя версия postgresql на Maven - 9.4.Добавить элемент JSON в массив с использованием postgres 9.4
Я в настоящее время структура JSON как это:
"playersContainer": {
"players": [
{
"id": "1",
"name": "Nick Pocock",
"teamName": "Shire Soldiers",
"bio" : "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla imperdiet lorem tellus, in bibendum sem dignissim sed. Etiam eu elit sit amet lacus accumsan blandit sed ut dolor. Mauris vel dui non nisi vestibulum commodo vel id magna. Donec egestas magna in tincidunt mollis. Fusce mauris arcu, rhoncus ut lacus sed, fermentum ultrices elit. In sollicitudin at ex dapibus vestibulum. Pellentesque congue, est id lobortis viverra, mauris lectus pharetra orci, ut suscipit nisl purus vehicula est. Aliquam suscipit non velit vel feugiat. Quisque nec dictum augue.",
"ratings": [
1,
5,
6,
9
],
"assists": 17,
"manOfTheMatches": 20,
"cleanSheets": 1,
"data": [
3,
2,
3,
5,
6
],
"totalGoals": 19
}
}
Я хочу, чтобы добавить новые игрок в массив игрока и обновить свою базу данных, я пытался делать обновление, но он вытер остальные данные. Есть ли способ настроить таргетинг на массив игроков и добавить к нему новый объект json?
Возможный дубликат [Прикрепление (толкание) и удаление из массива JSON в PostgreSQL 9.2, 9.3 и 9.4?] (http://stackoverflow.com/questions/30707482/appending-pushing-and-removing-from-a-json-array-in-postgresql- 9-2-9-3- и-9) –
Возможный дубликат [добавить объект json в массив в моей таблице postgres] (https://stackoverflow.com/questions/42076465/append-a-json-object-to-an-array-within-my-postgres-table) –