There should be essentially three different "flavors" for each structure:
Raw: this matches the structure of how pocketbase interprets and yields records (e.g. relation fields are ids, not populated)
Formatted: this is the uniform structure used to represent the data within the application context (e.g. relation fields are populated, and the structure is stable / independent of the persistence layer)
Expanded: this is a variant of Raw which allows us to include pocketbase expand in the raw interfaces for cases when expand is used.
NOTE: should we use the stable interface or the raw interface for setters?
The benefit of using raw interface is that we would not have to map the input
The downside is that the setters are then coupled to the persistence layer
I think that we should use the stable interfaces in the getters and setters so that the apis are more stable, even though this will require us to do some mapping for set operations. We should also set relations on data types with dedicated setters (e.g. setProduct will set the product on the list_item, instead of using an update(list_item, { product: '...' }) since this would couple the data layer to the persistence layer.)
There should be essentially three different "flavors" for each structure:
Raw
which allows us to include pocketbaseexpand
in the raw interfaces for cases whenexpand
is used.NOTE: should we use the stable interface or the raw interface for setters?
I think that we should use the stable interfaces in the getters and setters so that the apis are more stable, even though this will require us to do some mapping for set operations. We should also set relations on data types with dedicated setters (e.g. setProduct will set the product on the list_item, instead of using an update(list_item, { product: '...' }) since this would couple the data layer to the persistence layer.)