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

add database.all #159

Closed
wants to merge 3 commits into from
Closed

add database.all #159

wants to merge 3 commits into from

Conversation

SubandiK
Copy link
Contributor

@SubandiK SubandiK commented Jun 2, 2023

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

Copy link
Owner

@langalex langalex left a 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', {}, {})
Copy link
Owner

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', {}, {})
Copy link
Owner

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.

@SubandiK
Copy link
Contributor Author

SubandiK commented Aug 1, 2023

I'm not so sure what value this provides. calling .view with no keys already gives you all model instances .

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?

@SubandiK SubandiK closed this Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants