How to update a field that is part of the primary key

In my application am using Record layer. I have a use case where I want to update my primary key. My primary key is made up of three fields [CATEGORY, TYPE, VALUE].

My existing record is [C1,T1,V1]. I want to modify this to [C1,T1,V2]. How do i achieve this. Is doing a delete + insert my only option?

Yeah, that’s right, one deleteRecord call to remove the old record with the old primary key and one saveRecord call with the new primary key. If those are all done in the same transaction, then that will appear to be atomic to all other observers (i.e., anything outside that transaction), so it will have the desired move semantics that you’re trying to achieve.

We’ve considered adding things like an “update” API that allows you to read a record and produce an updated version to replace it with, but that would have to be (more or less) syntactic sugar over what’s described above.

1 Like