我正在尝试运行此聚合以针对MongoDB与Mongoose创建持久连接:
await HourLog.aggregate([
{
$lookup: {
from: 'timeentries',
localField: '_id',
foreignField: 'hourLog',
as: 'timeEntries'
}
},
{ $out: 'hourlogs' }
]);
使用Mongo 3.6.6版和Mongoose 4.8.7版
我收到此错误:
Error: The 'cursor' option is required, except for aggregate with the explain argument
我尝试添加光标选项:
await HourLog.aggregate([
{
$lookup: {
from: 'timeentries',
localField: '_id',
foreignField: 'hourLog',
as: 'timeEntries'
}
},
{ $out: 'hourlogs' }
], { $cursor: { } });
但是我收到一个新错误:
Error: Arguments must be aggregate pipeline operators
有什么想法吗?