```ts async function updatePost(id, newTitle) { const original = await DataStore.query(Post, id); if (original) { const updatedPost = await DataStore.save( Post.copyOf(original, updated => { updated.title = newTitle }) ); } } ``` ```js async function updatePost(id, newTitle) { const original = await DataStore.query(Post, id); const updatedPost = await DataStore.save( Post.copyOf(original, updated => { updated.title = newTitle }) ); } ``` Models in DataStore are *immutable*. To update a record you must use the `copyOf` function to apply updates to the item's fields rather than mutating the instance directly.