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
add database.all #159
add database.all #159
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not so sure what value this provides. calling .view with no keys already gives you all model instances .
def first!(spec) | ||
first(spec) || raise(CouchPotato::NotFound) | ||
end | ||
|
||
# returns all instances for a model | ||
def all(model) | ||
spec = CouchPotato::View::ModelViewSpec.new(model, 'all_model_instances', {}, {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is that view defined?
def first!(spec) | ||
first(spec) || raise(CouchPotato::NotFound) | ||
end | ||
|
||
# returns all instances for a model | ||
def all(model) | ||
spec = CouchPotato::View::ModelViewSpec.new(model, 'all_model_instances', {}, {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having one view per model is wasteful. imagine having 200 models. you could have one view where the model class is part of the key and use that to filter results.
the original inspiration was a model like (but not exactly, I forgot which it was) SpaceProfile, which doesn't have any views attached to it directly, and / or totally orphanaged models like some payment notification, where it would have been useful in support to just look at all of them and then filter for some attribute. Or maybe we can already do this and I'm just missing the correct syntax? |
Adds a database.all method that makes it possible to find e.g. all Invoices by saying db.all(Invoice).
To be used for debugging / finding records in one-off ways that don't warrant building a new view.
Note
the failing specs (for jruby, active_support_6_0) didn't start failing in this commit but earlier, in commit a185a80