Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Collection Group Queries #15

Open
elersong opened this issue Jul 13, 2024 · 0 comments
Open

Support for Collection Group Queries #15

elersong opened this issue Jul 13, 2024 · 0 comments
Labels
enhancement New feature or request from_willyovale An issue described in original project, but never implemented planning Not yet ready for development

Comments

@elersong
Copy link
Owner

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

  1. Attempt to query across subcollections with the same name using the current Fireorm implementation.
  2. 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

  1. 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();
  2. 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.
  1. 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.

Original Issue

@elersong elersong added enhancement New feature or request from_willyovale An issue described in original project, but never implemented planning Not yet ready for development labels Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request from_willyovale An issue described in original project, but never implemented planning Not yet ready for development
Projects
None yet
Development

No branches or pull requests

1 participant