<BlockSwitcher>

<Block name="Async/Await">

```swift
do {
    try await Amplify.DataStore.delete(post)
    print("Post deleted!")
} catch let error as DataStoreError {
    print("Error deleting post - \(error)")
} catch {
    print("Unexpected error \(error)")
}
```

</Block>

<Block name="Combine">

```swift
let sink = Amplify.Publisher.create {
    try await Amplify.DataStore.delete(post)
}.sink {
    if case let .failure(error) = $0 {
        print("Fetch session failed with error \(error)")
    }
}
receiveValue: {
    print("Post deleted!")
}
```

</Block>

</BlockSwitcher>

A delete can also be achieved by a `type` and its `id`.

<BlockSwitcher>

<Block name="Async/Await">

```swift
do {
    try await Amplify.DataStore.delete(Post.self, withId: "123")
    print("Post deleted!")
} catch let error as DataStoreError {
    print("Error deleting post - \(error)")
} catch {
    print("Unexpected error \(error)")
}
```

</Block>

<Block name="Combine">

```swift
let sink = Amplify.Publisher.create {
    try await Amplify.DataStore.delete(Post.self, withId: "123")
}.sink {
    if case let .failure(error) = $0 {
        print("Error deleting post - \(error)")
    }
}
receiveValue: {
    print("Post deleted!")
}
```

</Block>

</BlockSwitcher>
