Is there a way to call a function like jsonb_set?
I'd like to modify a jsonb object along a path without having to read the whole record, modify it and then write the whole record. For example:
insert into "user" ("modifiedDate", json)
values (CURRENT_TIMESTAMP,'{"id":"test","obj":{"a":1,"b":"string","c":true}}');
update "user"
set json = jsonb_set(json, '{obj,a}','2')
where json->>'id'='test'
It looks like we don't have that. I'm not sure why. Perhaps you'd like to try adding it along the lines of the other functions in Opaleye.Operators
Closing as stale. Feel free to reopen as necessary.
I'd like to take a stab at this as well as adding a range of other JSON/JSONB functions, however I have no idea where to start or to start looking for functions that are similar. If you could set me on the right path that'd be great. Specifically are there any examples of functions that return setof something that are already implemented in the library?
Here are a couple of examples of how one can expose SQL functions in Opaleye. Hope that helps. Let me know if you need more pointers.
https://github.com/tomjaguarpaw/haskell-opaleye/blob/1a5ef0246e82eed1937750f4d86a86aa6a33d3e4/src/Opaleye/Operators.hs#L337-L343
Thanks, I'll see if I can get around to it this weekend or most likely the one after. I'll let you know if I have any more questions.