```swift let post = Post( title: "My post with comments", rating: 5, status: .active ) let commentWithPost = Comment( content: "Loving Amplify DataStore", post: post ) do { let savedPost = try await Amplify.DataStore.save(post) let savedCommentWithPost = try await Amplify.DataStore.save(commentWithPost) } catch let error as DataStoreError { print("Failed with error \(error)") } catch { print("Unexpected error \(error)") } ``` ```swift let post = Post( title: "My post with comments", rating: 5, status: .active ) let commentWithPost = Comment( content: "Loving Amplify DataStore", post: post) let sink = Amplify.Publisher.create { try await Amplify.DataStore.save(post) } .flatMap { Amplify.Publisher.create { try await Amplify.DataStore.save(commentWithPost) } } .sink { if case let .failure(error) = $0 { print("Error adding post and comment - \(error.localizedDescription)") } } receiveValue: { print("Post and comment saved!") } ```