diff --git a/firestore/swift/firestore-smoketest/PipelineSnippets.swift b/firestore/swift/firestore-smoketest/PipelineSnippets.swift index 0e138fb..54922d9 100644 --- a/firestore/swift/firestore-smoketest/PipelineSnippets.swift +++ b/firestore/swift/firestore-smoketest/PipelineSnippets.swift @@ -27,6 +27,24 @@ public class PipelineSnippets { pipelineConcepts() } + func basicRead() async throws { + do { + // Initialize a Firestore Pipeline instance and specify the "users" collection as the + // input stage. + let snapshot = try await db.pipeline() + .collection("users") + .execute() // Execute the pipeline to retrieve documents. + + // Iterate through the documents in the pipeline results, similar to a regular query + // snapshot. + for result in snapshot.results { + print("\(result.id ?? "no ID") => \(result.data)") + } + } catch { + print("Error getting documents with pipeline: \(error)") + } + } + // https://cloud.google.com/firestore/docs/pipeline/overview#concepts func pipelineConcepts() { // [START pipeline_concepts] @@ -959,32 +977,6 @@ public class PipelineSnippets { print(result) } - // https://cloud.google.com/firestore/docs/pipeline/functions/logical_functions#is_nan - func isNaNFunction() async throws { - // [START is_nan] - let result = try await db.pipeline() - .collection("books") - .select([ - Field("rating").isNan().as("hasInvalidRating") - ]) - .execute() - // [END is_nan] - print(result) - } - - // https://cloud.google.com/firestore/docs/pipeline/functions/logical_functions#is_not_nan - func isNotNaNFunction() async throws { - // [START is_not_nan] - let result = try await db.pipeline() - .collection("books") - .select([ - Field("rating").isNotNan().as("hasValidRating") - ]) - .execute() - // [END is_not_nan] - print(result) - } - // https://cloud.google.com/firestore/docs/pipeline/functions/logical_functions#max func maxLogicalFunction() async throws { // [START max_logical_function]