I am rewrite the aggregation code for 100k records in my collection "auctions" and i need to create function for the reference of another stack overflow guide
How to increase mongodb BSON document size
but getting error for the
error TS2559: Type '(err: any, auctions: any) => void' has no properties in common with type 'CollectionCreateOptions'
how to get 100k records in BSON limit of more then 16MB in mongoDB
my code
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;
})
})