### Deleting records with custom primary keys

A record with a custom primary key can be deleted in the following ways:

With the value of the primary key:

<BlockSwitcher>

<Block name="Listener (iOS 11+)">

```swift
Amplify.DataStore.delete(Book.self, withIdentifier: .identifier(isbn: "12345")) { result in
    switch result{
    case .success:
        print("Book deleted!")
    case .failure(let error):
        print("Error deleting book: \(error)")
    }
}
```

</Block>

<Block name="Combine (iOS 13+)">

```swift
let sink = Amplify.DataStore.delete(Book.self, withIdentifier: .identifier(isbn: "12345")).sink {
    if case let .failure(error) = $0 {
        print("Error deleting book: \(error)")
    }
} receiveValue: {
    print("Book deleted!")
}
```
</Block>

</BlockSwitcher>

With the value of QueryPredicate:

<BlockSwitcher>

<Block name="Listener (iOS 11+)">

```swift
Amplify.DataStore.delete(Book.self, where: Book.keys.isbn == "12345") { result in
    switch result {
    case .success:
        print("Book deleted!")
    case .failure(let error):
        print("Error deleting book: \(error)")
    }
}
```
</Block>

<Block name="Combine (iOS 13+)">

```swift
let sink = Amplify.DataStore.delete(Book.self, where: Book.keys.isbn == "12345").sink {
    if case let .failure(error) = $0 {
        print("Error deleting book: \(error)")
    }
} receiveValue: {
    print("Book deleted!")
}
```
</Block>

</BlockSwitcher>