You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The goal is to have the domain models function completely independently of persistence. Currently they provide a more restricted interface than active record, but they still leak concerns up the stack, especially the query {} method.
Proposed Solution:
Follow the Repository pattern to provide an interface between Domain and Persistent models. The repository instance will have a method for each type of data that might be required by the front end. These methods will all take one parameter, an object holding the parameters to be used as input to the query. The repository class will be responsible for formulating the query, executing it, and returning the result data as domain models. The repository also has a "save!" method which receives a domain model and is responsible for persisting that domain model to whatever data store(s) are appropriate.
Note: ALL data lookup MUST be done through the Repository. That means queries take parameters related to authentication, pagination, whatever. All the data for the lookup must first be brought together, then the query can be executed and the results returned. This will make query optimization MUCH easier in future by keeping all queries in one place and making them easier to audit.
The text was updated successfully, but these errors were encountered:
After a solid attempt at this, I've decided that this is overly complex and doesn't necessarily bring us any real benefit. Decision made to go back to a pure ActiveRecord implementation, closing this out.
Goal:
The goal is to have the domain models function completely independently of persistence. Currently they provide a more restricted interface than active record, but they still leak concerns up the stack, especially the query {} method.
Proposed Solution:
Follow the Repository pattern to provide an interface between Domain and Persistent models. The repository instance will have a method for each type of data that might be required by the front end. These methods will all take one parameter, an object holding the parameters to be used as input to the query. The repository class will be responsible for formulating the query, executing it, and returning the result data as domain models. The repository also has a "save!" method which receives a domain model and is responsible for persisting that domain model to whatever data store(s) are appropriate.
Note: ALL data lookup MUST be done through the Repository. That means queries take parameters related to authentication, pagination, whatever. All the data for the lookup must first be brought together, then the query can be executed and the results returned. This will make query optimization MUCH easier in future by keeping all queries in one place and making them easier to audit.
The text was updated successfully, but these errors were encountered: