laravel mongodb jenssegers allowDiskUse true

时间:2018-02-03 09:25:43

标签: php mongodb laravel laravel-5

I use laravel-mongodb by jenssegers. I want to query a huge amount of data with order by and this is my query :

$stores = \App\StoreTransaction::where('date_time','>',1489944515)
        ->orderBy('date_time', 'asc')->get();

But I got this error:

Sort exceeded memory limit of 104857600 bytes

I know I should add allowDiskUse true to my query but how can i add it to mongodb jenssegers package ?

2 个答案:

答案 0 :(得分:2)

转到“ vendor / mongodb / mognodb / src / Operation / Aggregate.php” 转到“第133行”

每个'allowDiskUse'=> true 替换'allowDiskUse'=> false

答案 1 :(得分:1)

  

请不要修改供应商文件

根据您的情况,使用“选项”方法允许使用磁盘:

ObjectMapper mapper = new ObjectMapper();
String jsonInString = "{'name' : 'mkyong'}";

//JSON from file to Object
User user = mapper.readValue(new File("c:\\user.json"), Example.class);