Your code can result in a race condition when two request execute the above code at the same time. Hence, the tutorials use the jsonb_set, which performs the modification directly at DB level.
Heshie Brody currently serves as a Technical Lead at Morgan and Morgan PA, where he oversees the development of both web and mobile client experiences.
Your code can result in a race condition when two request execute the above code at the same time. Hence, the tutorials use the
jsonb_set
, which performs the modification directly at DB level.Good point. Wrote this when I was just starting out, should definitely revise this :)