Saving the results of an agregation pipeline into a text file

Silly me, I was too tired! I add now the curly brackets to my aggregation following your instruction and it works. I have my file with 3705 doublets!

{cursor = db.candidates.aggregate([{ $group: { _id: { name: "$name", xing: "$xing" }, count: { $sum: 1 }, docs: { $push: "$_id" } } }, { $match: { count: { $gt: 1 } } }]); cursorAsStream = stream.Readable.from(cursor.map((entry) => EJSON.stringify(entry) + '\n')); cursorAsStream.pipe(fs.createWriteStream('/home/blatta/Documents/IT-REC/doublets-2'));}

Thank you @Anna_Henningsen !

2 Likes

Hi @Pietro_Simcic ! Welcome! So glad to see other’s finding the answers to their aggregation questions. :open_book: Thanks for your expertise @Anna_Henningsen . We’ll get there with help from the pros!

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.