I'm storing the data in a jsonb field called members_json in PostgreSQL 9.5 in a table called event_members_json. I want to make a trigger that everytime an insert gets done on another table call event_members inserts the new event member into the array of the jsonb field.
The field jsonb field has the following structure:
{"members": [{"user_id": 1, "last_name": "argento", "first_name": "pepe", "firebase_id": "123", "profile_pic": "storage/image.png", "is_moderator": "t"}]}
which would be the syntax to insert a new member(json object) into the members array described above??...
Thank you very much!
->operator to get the "members" value,||operator to add the object to the array, andjsonb_setfunction to set the modified value of the "members" key. - Abelisto