【发布时间】:2021-10-14 14:49:22
【问题描述】:
我正在为我的收藏“拍卖”中的 100k 条记录重写聚合代码,我需要创建函数以供另一个堆栈溢出指南参考
How to increase mongodb BSON document size
但出现错误
error TS2559: Type '(err: any, auctions: any) => void' has no properties in common with type 'CollectionCreateOptions'
如何在 mongoDB 中获得超过 16MB 的 BSON 限制中的 10 万条记录
我的代码
db.collection("auctions", (err: any, auctions: any): any => {
if(err) throw err;
const result: any = [];
const cursor: any = auctions.aggregate(
[
{
$match: {
status: 'UNPAID'
}
},
{
$lookup: {
from: 'bids',
let: { id: '$_id' },
pipeline: [
{
$match: {
$expr: { $and: [{ $eq: ['$auctioncode', '$$id'] }] },
},
},
],
as: 'bids',
},
},
{
$facet: {
products: [{ $skip: 0 }, { $limit: 100000 }],
},
}
],
{
"allowDiskUse": true,
"cursor": { "batchSize": 20 }
}
);
cursor.on("data",(data: any) => {
result.push(data);
});
cursor.on("end",() => {
return result;
})
})
【问题讨论】:
标签: mongodb mongoose node-mongodb-native