Skip to content

Commit 0583ecb

Browse files
committed
add documentations
1 parent 7e5e71d commit 0583ecb

File tree

5 files changed

+20
-2
lines changed

5 files changed

+20
-2
lines changed

Firestore/Swift/Source/SwiftAPI/Pipeline/Options/GenericOptions.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
/// A container for providing arbitrary, backend-specific options to a pipeline.
16+
///
17+
/// Use this to pass options that are not explicitly defined in the other option structs.
1518
public struct CustomOptions: OptionProtocol {
1619
var values: [String: Sendable]
20+
/// Creates a set of custom options from a dictionary.
21+
/// - Parameter values: A dictionary containing the custom options.
1722
public init(_ values: [String: Sendable] = [:]) {
1823
self.values = values
1924
}

Firestore/Swift/Source/SwiftAPI/Pipeline/Options/IndexMode.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
/// Specifies which indexes the pipeline should use for execution.
1516
public struct IndexMode: Sendable, Equatable, Hashable {
1617
let rawValue: String
1718

19+
/// Use the set of indexes recommended by the backend.
1820
public static let recommended = IndexMode(rawValue: "recommended")
1921

2022
init(rawValue: String) {

Firestore/Swift/Source/SwiftAPI/Pipeline/Options/OptionProtocol.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
/// A protocol that all pipeline option types must conform to.
1516
public protocol OptionProtocol: Sendable {}

Firestore/Swift/Source/SwiftAPI/Pipeline/Pipeline.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ public struct Pipeline: @unchecked Sendable {
107107
/// }
108108
/// ```
109109
///
110+
/// - Parameters:
111+
/// - explainOptions: Configures the execution plan report for debugging and optimization. Use
112+
/// it to analyze performance, get index recommendations, and control the verbosity and format of
113+
/// the output.
114+
/// - indexMode: Specifies which indexes to use for the pipeline, such as the `.recommended`
115+
/// set.
116+
/// - customOptions: A dictionary for passing any other backend-specific or advanced options to
117+
/// the pipeline execution.
110118
/// - Throws: An error if the pipeline execution fails on the backend.
111119
/// - Returns: A `PipelineSnapshot` containing the result of the pipeline execution.
112120
public func execute(explainOptions: ExplainOptions? = nil,
@@ -149,7 +157,8 @@ public struct Pipeline: @unchecked Sendable {
149157
/// - Parameter field: The first field to add to the documents, specified as a `Selectable`.
150158
/// - Parameter additionalFields: Optional additional fields to add, specified as `Selectable`s.
151159
/// - Returns: A new `Pipeline` object with this stage appended.
152-
public func addFields(_ field: Selectable, _ additionalFields: Selectable...) -> Pipeline {
160+
public func addFields(_ field: Selectable, _ additionalFields: Selectable...,
161+
customOptions: [String: Sendable]? = nil) -> Pipeline {
153162
let fields = [field] + additionalFields
154163
return Pipeline(stages: stages + [AddFields(fields: fields)], db: db)
155164
}

Firestore/Swift/Tests/Integration/PipelineApiTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ final class PipelineTests: FSTIntegrationTestCase {
7777
_ = db.pipeline().collection("books")
7878
.addFields(
7979
Field("msrp").multiply(Field("discount")).as("salePrice"),
80-
Field("author")
80+
Field("author"),
81+
customOptions: ["option_not_known_to_sdk": true]
8182
)
8283

8384
// Output

0 commit comments

Comments
 (0)