我正在尝试运行此聚合以使用Mongoose针对MongoDB创建持久连接:
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
有任何想法吗?