How can I use “not like” on laravel mongodb?

☆樱花仙子☆ 提交于 2019-12-11 01:37:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!