There is a need to retrieve a model from the DocumentSnapshot provided by Firestore DB triggers. The current solution involves using plainToClass from class-transformer, but a more integrated approach within Fireorm would be beneficial.
Steps to Reproduce
Set up a Firestore DB trigger.
Attempt to retrieve a model directly from the DocumentSnapshot provided by the trigger.
Expected Behavior
A method within Fireorm that allows easy conversion of DocumentSnapshot to a model, enabling seamless use of Fireorm in Firestore DB triggers.
Actual Behavior
Currently, users need to manually convert the snapshot data to their model using plainToClass.
Acceptance Criteria
Develop a method (e.g., extractTFromDocSnap(docSnap)) within Fireorm to handle the conversion from DocumentSnapshot to a model.
Ensure the method works reliably with all fields declared in the model.
Consider future integration of Fireorm as a middleware in triggers to automatically translate payloads.
Additional Context
October 18, 2019: Initial inquiry about using Fireorm with Firestore DB triggers.
October 19, 2019: Suggested use of plainToClass as a temporary solution.
October 21, 2019: Discussion about exposing an internal function for converting document snapshots to models and the potential for future middleware integration.
July 3, 2020: Comment about the blocking nature of this issue and offer to help with a solution.
July 7, 2020: Mentioned in another issue related to using Fireorm with Firebase Client SDK.
Description
There is a need to retrieve a model from the
DocumentSnapshot
provided by Firestore DB triggers. The current solution involves usingplainToClass
fromclass-transformer
, but a more integrated approach within Fireorm would be beneficial.Steps to Reproduce
DocumentSnapshot
provided by the trigger.Expected Behavior
A method within Fireorm that allows easy conversion of
DocumentSnapshot
to a model, enabling seamless use of Fireorm in Firestore DB triggers.Actual Behavior
Currently, users need to manually convert the snapshot data to their model using
plainToClass
.Acceptance Criteria
extractTFromDocSnap(docSnap)
) within Fireorm to handle the conversion fromDocumentSnapshot
to a model.Additional Context
plainToClass
as a temporary solution.Original Issue