I have a bunch of records stored as objects in an array in a Vuex module. I want to create a STORE_RECORD mutation that receives a record object with an id property. If a record with the same id already exists in the array the mutation should replace that record with the record object it received, otherwise the new record object should be added to the array.
Since this must be a very common pattern I imagine there is an established or recommended way of doing this. Can anyone give me some example code for such a mutation?