spatie / laravel-query-builder

Easily build Eloquent queries from API requests
https://spatie.be/docs/laravel-query-builder
MIT License
4.06k stars 397 forks source link

Can this package be used with MongoDB model? #698

Closed mrlinnth closed 2 years ago

mrlinnth commented 2 years ago

Tried to search if mongodb is supported or not at old issues/discussion and couldn't find any.

Can someone help or guide me in the right direction?

I am connecting Mongo DB and want to use this package but facing issue.

image

weogrim commented 2 years ago

It seems to me that this package is not capable of working with MongoDB. I've been trying right now to find out why, and I locate Spatie\QueryBuilder\Filters\FiltersPartial which construct RAW SQL query:

(...)
$sql = "LOWER({$wrappedProperty}) LIKE ?";
(...)
$query->whereRaw($sql, ["%{$value}%"]);
mrlinnth commented 2 years ago

@weogrim yea I also concluded that this is not compatible for MongoDB models yet.

Since I am developing a REST API app, I have switched to laraveljsonapi package instead.

klimov-paul commented 2 years ago

You may try to use illuminatech/data-provider instead.

ce-brex commented 2 years ago

Just ran into this issue as well, my current workaround is to use Filter::callback() or Filter::custom() instead.