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

Option to Omit Sub-Collections from Queries #17

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

Option to Omit Sub-Collections from Queries #17

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

There are scenarios where certain queries need to omit sub-collections, particularly when the data is being ingested by a third party. Providing a configuration option to disable sub-collection initialization on a per-request basis would be valuable.

Steps to Reproduce

  1. Perform a query using Fireorm that returns documents with sub-collections.
  2. Attempt to omit sub-collections from the query results without additional processing.

Expected Behavior

Ability to configure queries to exclude sub-collections from the results, either on a per-request basis or as a global setting.

Actual Behavior

Currently, sub-collections are always initialized, and developers must manually remove them if not needed.

Acceptance Criteria

  • Implement a configuration option to disable sub-collection initialization on a per-request basis.
  • Ensure the feature is optional and enabled by default.
  • Consider adding a global setting to disable sub-collection initialization for the entire project.

Additional Context

  • May 21, 2020: Initial issue raised about the need to omit sub-collections from certain queries.
  • June 6, 2020: Discussion on the feasibility and design of the proposed feature, including the possibility of a project-wide toggle.

Proposed API Changes

  1. Per-Request Configuration:

    • Add an optional parameter to query methods to disable sub-collection initialization.
    • Example:
      getRepository(Product).findById('1234', { initializeSubcollections: false });
  2. Global Configuration:

    • Introduce a global setting in the Fireorm initialization to disable sub-collection initialization for all queries.
    • Example:
      initialize({ initializeSubcollections: false });
  3. Default Behavior:

    • Ensure that sub-collection initialization is enabled by default to maintain backward compatibility.
    • Allow developers to override this behavior per query or for the entire project as needed.
  4. Implementation Considerations:

    • Ensure the implementation is clean and does not introduce significant overhead or complexity.
    • Provide clear documentation on how to use the new configuration options.

Example Usage

// Disable sub-collections for a specific query
const product = await getRepository(Product).findById('1234', { initializeSubcollections: false });

// Disable sub-collections globally
initialize({ initializeSubcollections: false });

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