Hi all,
I trying to implement a simple comment section where users can add comments to a particular entry in our database.
I've set up a column in my postgres table with the following settings. The postgres type is JSONB with a default value of {}
:
Here is a simplified version of the query. It useS the spread operator as seen on this post.
The first time the query runs I end up with this in my table:
{"person": "person A", "comment": "this is a comment"}
(I would have expected { {} , {"person": "person A", "comment": "this is a comment"}}
)
But after this, whenever the query runs I end up with the same result:
{"person": "person A", "comment": "this is a comment"}
and not {{}, {"person": "person A", "comment": "this is a comment"}, {"person": "person A", "comment": "this is a comment"} }
I guess I'm overlooking something simple but haven't been able to work it out yet, could someone point me in the right direction? Any help is appreciated!