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

Change Collection#where so it behaves like Model#where #2001

merged 4 commits into from
Aug 11, 2019


Copy link


This makes Collection#where() constrain fetch() queries, so that it behaves like Model#where().


The fact that there are two methods called where that do different things is confusing. It should be expected that when operating on both Models and Collections the where() method would always constrain additional queries.

Closes #780.

Proposed solution

The current behavior of Collection#where() was changed so that it calls .query('where', ...args). Additionally, Collection#findWhere() was removed since it too is a bit confusing and its functionality can be achieved with Collection#find.

Current PR Issues

This change is not backwards compatible. Check the migration guide on how to change your code if you were relying on any of the Collection#where() or Collection#findWhere() methods.

- This makes it behave like the equivalent Model#where method that is 
just a shortcut for calling `.query('where', ...args)`.
- It's a bit confusing considering the similarity of its name with 
Collection#where, and it's not needed since the same functionality can 
be achieved by using Collection#filter.
@ricardograca ricardograca merged commit 36eb9c2 into master Aug 11, 2019
@ricardograca ricardograca deleted the rg-collection-where branch August 11, 2019 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.

Surprising inconsistency between Model#where and Collection#where.
1 participant