Subcollection
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 7, *)
public class Subcollection : Pipeline, @unchecked SendableA Subcollection is a special type of pipeline constructed for sub-queries.
It is not tied to a primary database instance upfront and cannot be executed directly;
instead, it is intended to be converted into an array or scalar expression and used within
another pipeline's stage (such as addFields).
// Calculate the average rating of reviews for each book and add it as a field.
firestore.pipeline().collection("books")
.addFields([
Subcollection("reviews")
.aggregate([Field("rating").average().as("avgRating")])
.toScalarExpression().as("averageRating")
])
-
Initializes a Subcollection Pipeline centered on a target path.
Declaration
Swift
public init(_ path: String)Parameters
pathThe location of the subcollection or relative target.