-
Notifications
You must be signed in to change notification settings - Fork 19
Backend Pattern Query
Ferris Tseng edited this page Jan 2, 2020
·
4 revisions
Query objects store complex SQL queries, data aggregation, and filtering methods. 1
app/queries
- The Query object should take a relation as it's argument, that should enable the caller to control the scope of the query.
- Query objects should be composable.
- Should return an
ActiveRecord::Relation
.
Note: In practice, it's difficult to achieve some of these desired qualities because Caseflow's data spans multiple databases.
Use the Service pattern if you are encapsulating complex logic that requires a read.
Pattern | Description |
---|---|
Service | Alternative for database logic that requires writes |