我尝试在我的laravel应用中运行mongo查询,但收到此帖子标题中列出的错误。我想我需要将useCursor
设置为true
,但无法让它发挥作用。这是我的代码:
$email_duplicates = User::raw(function ($collection) {
return $collection->aggregate(
[
[
'$group' => [
'_id' => [
'email' => '$email',
],
'uniqueIds' => [
'$addToSet' => '$_id',
],
'count' => [
'$sum' => 1,
],
],
],
[
'$match' => [
'count' => [
'$gt' => 1,
],
],
],
],
[
'allowDiskUse' => true,
],
[
'useCursor' => true,
]
);
});
任何人都知道我做错了什么?
谢谢!