Skip to content

Commit 0b7a061

Browse files
authored
Add missing snippet tag and fix missing param error (#415)
* remove stable snippet * snippet updates
1 parent 710a22d commit 0b7a061

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

firestore/swift/firestore-smoketest/PipelineSnippets.swift

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,22 @@ public class PipelineSnippets {
2727
pipelineConcepts()
2828
}
2929

30-
func basicRead() async throws {
30+
func stagesExpressionsExample() async throws {
31+
// [START stages_expressions_example]
32+
guard let cutoffDate = Calendar.current.date(byAdding: .month, value: -1, to: Date()) else {
33+
return
34+
}
35+
let snapshot = try await db.pipeline()
36+
.collection("productViews")
37+
.where(Field("viewedAt").greaterThan(cutoffDate.timeIntervalSince1970))
38+
.aggregate([Field("productId").countDistinct().as("uniqueProductViews")])
39+
.execute()
40+
// [END stages_expressions_example]
41+
print(snapshot)
42+
}
43+
44+
func basicRead() async {
45+
// [START basic_read]
3146
do {
3247
// Initialize a Firestore Pipeline instance and specify the "users" collection as the
3348
// input stage.
@@ -43,6 +58,7 @@ public class PipelineSnippets {
4358
} catch {
4459
print("Error getting documents with pipeline: \(error)")
4560
}
61+
// [END basic_read]
4662
}
4763

4864
// https://cloud.google.com/firestore/docs/pipeline/overview#concepts
@@ -1149,6 +1165,7 @@ public class PipelineSnippets {
11491165
])
11501166
.execute()
11511167
// [END to_lower]
1168+
print(result)
11521169
}
11531170

11541171
// https://cloud.google.com/firestore/docs/pipeline/functions/string_functions#substr
@@ -1185,7 +1202,7 @@ public class PipelineSnippets {
11851202
let result = try await db.pipeline()
11861203
.collection("books")
11871204
.select([
1188-
Field("name").trim().as("whitespaceTrimmedName")
1205+
Field("name").trim(" \n\t").as("whitespaceTrimmedName")
11891206
])
11901207
.execute()
11911208
// [END trim_function]

0 commit comments

Comments
 (0)