Skip to content
This repository has been archived by the owner on May 13, 2021. It is now read-only.

Ability to use where() method #8

Merged
merged 2 commits into from
Apr 20, 2020
Merged

Conversation

Cannonb4ll
Copy link
Contributor

@Cannonb4ll Cannonb4ll commented Apr 20, 2020

Related issue: #7

This PR allows the usage of a basic where() method to be able to filter on tenants for example.

Code example:

\App\User::search('a')->where('tenant_id', 1)->get();

You can chain multiple where's, it currently applies the AND statement if you add more than 1 where method.

Single where URI:
?q=a&filters=tenant_id%3D1

Multiple values:
?q=a&filters=tenant_id%3D1+AND+name%3DHi+AND+email%3Dtest%40example.com

@curquiza curquiza requested a review from shokme April 20, 2020 14:02
@shokme
Copy link
Collaborator

shokme commented Apr 20, 2020

Good work @Cannonb4ll
The only problem is the $value must be escaped by ".
https://docs.meilisearch.com/guides/advanced_guides/filtering.html#conditions

NOTE

string values are either double-quoted, single-quoted or a single unquoted word: title = "Scream", >title = 'Scream' and title = Scream are all valid syntaxes, title = The Avengers is not.

Example of error I get when using where('foo', 'bar baz');
filter parsing error: parsing error on line 1 at column 15: expected other, AND, or OR

@Cannonb4ll
Copy link
Contributor Author

Good one! I tested and inserted your suggestion👏

@shokme shokme merged commit 24b84d9 into meilisearch:master Apr 20, 2020
@shokme shokme linked an issue Apr 20, 2020 that may be closed by this pull request
@curquiza
Copy link
Member

Thanks for your work guys!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is the where method available?
3 participants