Skip to content

Conversation

@ricardograca
Copy link
Member

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 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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Surprising inconsistency between Model#where and Collection#where.

2 participants