```swift
let p = Post.keys
do {
let result = try await Amplify.DataStore.query(Post.self, where: p.rating > 4)
print("Posts: \(result)")
} catch let error as DataStoreError {
print("Error listing posts - \(error)")
} catch {
print("Unexpected error \(error)")
}
```
```swift
let p = Post.keys
let sink = Amplify.Publisher.create {
try await Amplify.DataStore.query(Post.self, where: p.rating > 4)
}.sink {
if case let .failure(error) = $0 {
print("Error listing posts - \(error)")
}
}
receiveValue: { result in
print("Posts: \(result)")
}
```