Firebase Firestore has a select method that allows retrieving specific fields from a document, similar to the SELECT statement in SQL. This feature can be beneficial for improving performance by reducing the amount of data transferred over the network. Currently, Fireorm does not support this feature.
Steps to Reproduce
Attempt to use the select method in Fireorm to retrieve specific fields from a document.
Notice that the feature is not implemented.
Expected Behavior
Ability to use a select method to specify which fields to retrieve from a document, reducing the amount of data transferred and improving performance.
Actual Behavior
Fireorm always returns the entire document, which can lead to unnecessary data transfer and performance issues.
Acceptance Criteria
Implement a select method in Fireorm that allows specifying which fields to retrieve from a document.
Ensure the API is type-safe and intuitive to use.
Provide documentation and examples on how to use the new feature.
Additional Context
September 1, 2020: Initial request to implement a select method for partial document retrieval.
September 8, 2020: Acknowledgment that the feature is not implemented and request for API design ideas.
September 30, 2020: Agreement on the usefulness of the feature and call for ideas.
Proposed API Changes
Introduce Select Method:
Add a select method to the repository that allows specifying which fields to retrieve.
// Example usage
const partialUser = await getRepository(User).select('display_name', 'username').findById(userId);
Type-Safe API:
Ensure that the select method is type-safe, providing autocomplete and type checking for field names.
Implementation Details:
Modify the query builder to support the select method.
Ensure that the select method integrates seamlessly with existing query methods in Fireorm.
Provide thorough testing to validate the new functionality and ensure it does not introduce any regressions.
Example Implementation
@Collection()
class User {
id: string;
display_name: string;
username: string;
email: string;
}
// Repository instance
const repo = getRepository(User);
// Retrieve only specific fields
const partialUser = await repo.select('display_name', 'username').findById(userId);
Description
Firebase Firestore has a
select
method that allows retrieving specific fields from a document, similar to the SELECT statement in SQL. This feature can be beneficial for improving performance by reducing the amount of data transferred over the network. Currently, Fireorm does not support this feature.Steps to Reproduce
select
method in Fireorm to retrieve specific fields from a document.Expected Behavior
Ability to use a
select
method to specify which fields to retrieve from a document, reducing the amount of data transferred and improving performance.Actual Behavior
Fireorm always returns the entire document, which can lead to unnecessary data transfer and performance issues.
Acceptance Criteria
select
method in Fireorm that allows specifying which fields to retrieve from a document.Additional Context
select
method for partial document retrieval.Proposed API Changes
Introduce Select Method:
select
method to the repository that allows specifying which fields to retrieve.Type-Safe API:
select
method is type-safe, providing autocomplete and type checking for field names.Implementation Details:
select
method.select
method integrates seamlessly with existing query methods in Fireorm.Example Implementation
Original Issue