FireORM currently requires collection classes to have parameterless constructors to initialize instances. This limitation forces developers to add undefined and null types to all class attributes to satisfy TypeScript's strict mode, leading to potential issues with data storage and unnecessary null values being written to the datastore.
Steps to Reproduce
Create a collection class with attributes.
Add a parameterless constructor to comply with FireORM requirements.
Attempt to initialize the class with data, encountering TypeScript errors if attributes are not undefined or null.
Expected Behavior
Allow collection classes to have constructors with parameters to initialize data while still supporting FireORM's initialization process. Ensure undefined values are not written to the datastore to avoid storage issues and maintain data integrity.
Actual Behavior
Developers must add undefined and null types to attributes, leading to unnecessary null values in the datastore.
Acceptance Criteria
Allow collection classes to have constructors with parameters, handling undefined parameters when invoked by FireORM.
Ensure undefined values are not written to the datastore.
Maintain compatibility with TypeScript's strict mode without requiring additional types for attributes.
Additional Context
November 11, 2019: Initial issue raised about the limitation of parameterless constructors.
November 19, 2019: Discussion about the challenges of overloading constructors in JavaScript/TypeScript.
November 28, 2019: Suggestions for workarounds using factory methods or TypeScript-specific constructor overloading.
April 22, 2020: Referenced in issues about type assignability and strict property initialization.
November 13, 2020: Mentioned in a feature request to add constructor support to the Collection decorator.
Description
FireORM currently requires collection classes to have parameterless constructors to initialize instances. This limitation forces developers to add
undefined
andnull
types to all class attributes to satisfy TypeScript's strict mode, leading to potential issues with data storage and unnecessary null values being written to the datastore.Steps to Reproduce
undefined
ornull
.Expected Behavior
Allow collection classes to have constructors with parameters to initialize data while still supporting FireORM's initialization process. Ensure undefined values are not written to the datastore to avoid storage issues and maintain data integrity.
Actual Behavior
Developers must add
undefined
andnull
types to attributes, leading to unnecessary null values in the datastore.Acceptance Criteria
Additional Context
Original Issue