In order to use thecollection_groupstage, it must appear as the first stage
in the pipeline.
The order of documents returned from thecollection_groupstage is unstable
and shouldn't be relied upon. A subsequent sort stage can be used to obtain a
deterministic ordering.
For example, for the following documents:
Node.js
awaitdb.collection('cities/SF/departments').doc('building').set({name:'SF Building Deparment',employees:750});awaitdb.collection('cities/NY/departments').doc('building').set({name:'NY Building Deparment',employees:1000});awaitdb.collection('cities/CHI/departments').doc('building').set({name:'CHI Building Deparment',employees:900});awaitdb.collection('cities/NY/departments').doc('finance').set({name:'NY Finance Deparment',employees:1200});
Thecollection_groupstage can be used to return documents from every
departments collection across all parent collections in the database.
{name:'SF Building Deparment',employees:750}{name:'CHI Building Deparment',employees:900}{name:'NY Building Deparment',employees:1000}{name:'NY Finance Deparment',employees:1200}
[[["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-01-15 UTC."],[],[]]