I am trying to add items to a JSON array using jsonb_insert as:
jsob_insert(document, '{path,to,array,0}','{"key":"value"}')
This inserts {"key":"value"} to the head of array. However, I want to do this insert iff the JSON object {"key":"value"} does not already exist in the array. Currently, it just adds it to the array without caring about duplicacy (which is how it is intended to work). I am just wondering if there is a way to take care of duplicate records this way.