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
merged 4 commits into from Aug 11, 2019

Conversation

@ricardograca
Copy link
Member

commented Aug 10, 2019

  • Related Issues: #780

Introduction

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

Motivation

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 added the change label Aug 10, 2019
@ricardograca ricardograca merged commit 36eb9c2 into master Aug 11, 2019
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@ricardograca ricardograca deleted the rg-collection-where branch Aug 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.