RefirebaseRefirebase

getGroup

new

Query across all subcollections with the same name.

Usage

Use db.firestore.getGroup to fetch documents from any subcollection sharing the same name using Firestore's collectionGroup feature.

Collection group query
import { db } from 'refirebase';

const result = await db.firestore.getGroup('messages', {
  orderBy: [{ field: 'created_at', direction: 'desc' }],
  limit: 50,
});

if ('error' in result) {
  console.error('Error fetching group:', result.error);
} else {
  console.log('Group results:', result);
}

Parameters

ParamTypeDescription
collectionId*stringThe ID of the collection group to query (e.g., 'messages').
optionsGetByConditionQuery modifiers like where clauses, orderBy, limit, and startAfter.

Return value

Returns

Promise<ReturnGenericObj<T>[] | FirestoreError>

Returns an array of matched documents or an error object.