[Feature Request] whereLike
Describe the feature
While we wait for the possibility of https://github.com/vuex-orm/plugin-search being ported to pinia-orm..
I tried doing something like this:
useRepo(Project).query().where('name', 'like', `%${this.query}%`).get();
I didn't get any errors, but it also didn't work.
It would be nice if you could add a whereLike helper.
I ended up going with this
useRepo(Project).query().where('name', (value) => {
return value.toLowerCase().includes(this.query.toLowerCase());
}).get();
Which works well enough..
Thanks!
Additional information
- [X] Would you be willing to help implement this feature?
Final checks
- [X] Check existing discussions and issues.
I can try to add the keyword like to where clause. But i don't think i add a helper for it because i am orientanting on laravel syntax. And laravel doesn't have it.
As you wish. I've been using a whereLike macro in Laravel for many years now.. originally made popular through Spatie's twitter account.
For pinia-orm I ended up going for something like this:
filteredPosts() {
const query = useRepo(Post).query();
let results = [];
if (this.query.length >= this.minQuery) {
query.where('title', (value) => {
return value.toLowerCase().includes(this.query.toLowerCase());
});
results = query.get();
this.queryResults.posts = results.length;
}
return results;
},
But this clearly is nowhere near as convenient or versatile as vuex-orm's search plugin