I'm working with JSONB in Postgres and trying to understand how to correctly perform an assignment to a JSON property in plpgsql.
This query snippet reports a syntax error because of the leading bracket on the assignment, however I was fairly sure this syntax was required to refer to JSON objects in plpgsq:
IF (NEW."data")->>'custom' IS NULL THEN
(NEW."data")->>'custom' := 0;
This is in a postgresql trigger, so NEW is the provided variable relating to the new database record.
Can someone advise what the correct technique is for assigning a value to a JSON(B) property?