我有一个包含 100 万个文档的集合......我已经通过了选项allowDiskUse,现在它抛出错误
TypeError: callback.apply is not a function
我已经搜索过这个,但可以得到解决方案...请帮忙
const pictures = await Picture.aggregate([
{ $sort: { createdAt: -1 }},
{ $group: {
_id: { $dateToString: { format: "%Y-%m-%d", date: "$createdAt" } },
pictures: {
$push: {
_id: '$_id',
image: '$image',
time: { $dateToString: { format: "%H:%M:%S", date: "$createdAt" } }
}
}
}},
{ $limit: 50 },
{ $project: {
_id: false,
createdAt: '$_id',
pictures: '$pictures'
}}
], { allowDiskUse: true })
Run Code Online (Sandbox Code Playgroud)
Mongodb 版本 - 3.6 …
mongoose mongodb node.js mongodb-query aggregation-framework