Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 18 additions & 26 deletions firestore/swift/firestore-smoketest/PipelineSnippets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
Loading