Firestore supports collection group queries, allowing you to search across multiple collections or subcollections with the same name. This feature is useful for querying data without needing to know the parent record. The proposed syntax for this feature in Fireorm is to use a collectionGroup function that derives the collection name from the entity.
Steps to Reproduce
Attempt to query across subcollections with the same name using the current Fireorm implementation.
Note the lack of support for collection group queries.
Expected Behavior
Ability to perform collection group queries using a syntax like collectionGroup(Entity).where(...).
Actual Behavior
Currently, Fireorm does not support collection group queries, limiting the ability to search across multiple collections or subcollections with the same name.
Acceptance Criteria
Implement a collectionGroup function in Fireorm that supports collection group queries.
Derive the collection group name from the entity name.
Ensure type safety using Fireorm's QueryBuilder.
Provide a light wrapper around collectionGroup and QueryBuilder to facilitate collection group queries.
Additional Context
November 29, 2019: Initial issue raised with a proposed syntax for collection group queries.
December 2-4, 2019: Discussion on how to derive the collection group name from the entity and the need for an intermediate utility function.
May 30, 2020: Inquiry about progress and use cases for querying specific subcollections across collections.
June 1, 2020: Discussion on modeling the collectionGroup method and using Fireorm's QueryBuilder for type safety.
August 4, 2020: Mentioned in another issue related to collection group queries.
Proposed API Changes
collectionGroup Function:
Introduce a collectionGroup function to support collection group queries.
Derive the collection group name from the entity name, similar to how collections are named when saved in the database.
// Example usage
const albumRepository = collectionGroup(Album);
const album70s = albumRepository.whereLessThan('releaseDate', new Date('1980-01-01')).find();
QueryBuilder Integration:
Use Fireorm's QueryBuilder to ensure type safety for the collection group queries.
Implement a light wrapper around collectionGroup and QueryBuilder to facilitate seamless integration and querying.
Utility Function:
Consider implementing an intermediate utility function to extract the intended collection group name.
Ensure the utility function accurately derives the collection name from the entity, accommodating scenarios where an entity might belong to multiple collection groups.
Description
Firestore supports collection group queries, allowing you to search across multiple collections or subcollections with the same name. This feature is useful for querying data without needing to know the parent record. The proposed syntax for this feature in Fireorm is to use a
collectionGroup
function that derives the collection name from the entity.Steps to Reproduce
Expected Behavior
Ability to perform collection group queries using a syntax like
collectionGroup(Entity).where(...)
.Actual Behavior
Currently, Fireorm does not support collection group queries, limiting the ability to search across multiple collections or subcollections with the same name.
Acceptance Criteria
collectionGroup
function in Fireorm that supports collection group queries.QueryBuilder
.collectionGroup
andQueryBuilder
to facilitate collection group queries.Additional Context
collectionGroup
method and using Fireorm'sQueryBuilder
for type safety.Proposed API Changes
collectionGroup Function:
collectionGroup
function to support collection group queries.QueryBuilder Integration:
Utility Function:
Original Issue