简体   繁体   中英

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

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?

我相信无论如何都会将like转换为regex,因此您可以像not regexp

$user = Comment::where('body', 'not regexp', '/spam/i'))->get();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM