我正在尝试创建一个位置,例如在Laravel中使用MongoDb作为搜索栏。在我用以下方法创建的mysql中:
DB::table('Account')->where('avail_balance','like','%' .$searchValue . '%');
但是使用MongoDb Jenssegers,我无法使用它。它什么也没返回。
在这里搜索一些帖子后,我使用:
$account = DB::connection('mongodb')->collection('Account')->where('avail_balance',"%{$searchValue}%")->paginate(5);
它仍然不返回任何内容。
我应该如何将该查询从mysql转换为mongodb?
非常感谢你!
答案 0 :(得分:1)
尝试使用 get()
方法的结尾:
DB::table('Account')->where('avail_balance','LIKE','%'.$searchValue.'%')->get();
并使用 LIKE
查询尝试此操作:
$account = DB::connection('mongodb')->collection('Account')->where('avail_balance','LIKE','%'.$searchValue.'%')->paginate(5);
我希望这会有所帮助。