```swift
var existingPost: Post = /* get an existing post */
existingPost.title = "[updated] My first post"
do {
try await Amplify.DataStore.save(existingPost)
print("Updated the existing post")
} catch let error as DataStoreError {
print("Error updating post - \(error)")
} catch {
print("Unexpected error \(error)")
}
```
```swift
var existingPost: Post = /* get an existing post */
existingPost.title = "[updated] My first post"
let postForUpdate = existingPost
let saveSink = Amplify.Publisher.create {
try await Amplify.DataStore.save(existingPost)
}.sink {
if case let .failure(error) = $0 {
print("Error updating post - \(error)")
}
}
receiveValue: {
print("Updated the existing post: \($0)")
}
```