```swift let p = Post.keys Amplify.DataStore.query(Post.self, where: p.rating > 4 && p.status == PostStatus.active) { switch $0 { case .success(let result): // result of type [Post] print("Published posts with rating greater than 4: \(result)") case .failure(let error): print("Error listing posts - \(error.localizedDescription)") } } ``` ```swift let p = Post.keys let sink = Amplify.DataStore.query( Post.self, where: p.rating > 4 && p.status == PostStatus.active ).sink { if case let .failure(error) = $0 { print("Error listing posts - \(error.localizedDescription)") } } receiveValue: { result in print("Published posts with rating greater than 4: \(result)") } ``` You can also write this in a compositional function manner by replacing the operators with their equivalent predicate statements such as `.gt`, `.and`, etc: ```swift let p = Post.keys Amplify.DataStore.query(Post.self, where: p.rating.gt(4).and(p.status.eq(PostStatus.active))) { // handle the callback like in the previous example } ``` ```swift let p = Post.keys let sink = Amplify.DataStore.query( Post.self, where: p.rating > 4 && p.status == PostStatus.active ).sink { // handle the callback like in the previous example } ```