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

**URL:** <https://forums.foundationdb.org/t/how-to-update-a-field-that-is-part-of-the-primary-key/2121>\
**Category:** Record Layer\
**Created:** [May 14, 2020, 5:32am UTC](https://forums.foundationdb.org/t/how-to-update-a-field-that-is-part-of-the-primary-key/2121 "2020-05-14T05:32:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![legilimen](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@legilimen](https://forums.foundationdb.org/u/legilimen)\
**Post date:** [May 14, 2020, 5:32am UTC](https://forums.foundationdb.org/t/how-to-update-a-field-that-is-part-of-the-primary-key/2121/1 "2020-05-14T05:32:55Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![alloc](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/alloc/32/9_2.png) [@alloc](https://forums.foundationdb.org/u/alloc)\
**Post date:** [May 21, 2020, 12:30am UTC](https://forums.foundationdb.org/t/how-to-update-a-field-that-is-part-of-the-primary-key/2121/2 "2020-05-21T00:30:52Z")

</div>

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.
