A 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")])
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-07-08 UTC."],[],[]]