问题
I see here : https://github.com/jenssegers/laravel-mongodb
I try :
$user = Comment::where('body', 'like', '%spam%')->get();
It works
But when I try :
$user = Comment::where('body', 'not like', '%spam%')->get();
It does not work
Seems the library not support not like
Whether there are any people who know how to circumvent this?
回答1:
I believe like
is converted to regex anyway, so you can do it as not regexp
:
$user = Comment::where('body', 'not regexp', '/spam/i'))->get();
来源:https://stackoverflow.com/questions/42814099/how-can-i-use-not-like-on-laravel-mongodb