Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Storage Interface #27

Closed
undergroundwebdesigns opened this issue Jan 27, 2015 · 1 comment
Closed

Refactor Storage Interface #27

undergroundwebdesigns opened this issue Jan 27, 2015 · 1 comment
Assignees

Comments

@undergroundwebdesigns
Copy link
Contributor

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.

@undergroundwebdesigns
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant