Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

[QUESTION] About scopes #16

Open
gosukiwi opened this issue Jul 13, 2020 · 0 comments
Open

[QUESTION] About scopes #16

gosukiwi opened this issue Jul 13, 2020 · 0 comments

Comments

@gosukiwi
Copy link

Hi guys! I apologize in advance if this is out of place (feel free to close this issue if that's the case) but I do have some questions about Clean Architecture and the way it's implemented here.

I am personally trying to wrap my head around Clean Architecture, and while it sounds great in theory, taking it to practice is quite hard.

My first question is, is it a demo app somewhere I can see? :)

My other question is about scopes. What I understand to be the goal of CA (or at least one of it's goals) is to move the domain logic to it's own place, independent of Rails, Sinatra, the CLI or whatever you use to deliver your app.

That sounds great and all, but I found ActiveRecord to be so closely tied to Rails-land that it's really hard to abstract it away. Particularly for reading complex data/queries.

For example, one blocker I have are scopes. To define scopes (say, Admins can see all Post entities but Users can see only those where(published: true)) you need to a way to filter the results from the database (ActiveRecord::Relation most likely) on the domain-side somehow.

Is there a way to use scopes with this implementation? For example, implementing a use case FindHotStories where it returns the last 10 hot stories where publish is true if you are a regular user, and just all the stories if you are an admin.

Thanks for your time 😄

Cheers!

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

No branches or pull requests

1 participant