<BlockSwitcher>

<Block name="Async/Await">

```swift
let p = Post.keys
do {
    let result = try await Amplify.DataStore.query(
        Post.self,
        where: p.rating == nil || p.status == PostStatus.active
    )
    // result of type [Post]
    print("Posts in draft or without rating: \(result)")
} catch let error as DataStoreError {
    print("Error listing posts - \(error)")
} catch {
    print("Unexpected error \(error)")
}
```

</Block>

<Block name="Combine">

```swift
let p = Post.keys
let sink = Amplify.Publisher.create {
    try await Amplify.DataStore.query(
        Post.self,
        where: p.rating == nil || p.status == PostStatus.active
    )
}.sink {
    if case let .failure(error) = $0 {
        print("Error listing posts - \(error)")
    }
}
receiveValue: { result in
    // result of type [Post]
    print("Posts in draft or without rating: \(result)")
}
```

</Block>

</BlockSwitcher>
