Parallel collectionScan using node.js

I want to get count and documents for more than 5lakhs records by using parallel collection scan using node js.

Hello :wave: @Santhosh_V,

If I understand the question correctly, you want to use parallelCollectionScan. It’s important to note that the parallelCollectionScan command was removed in MongoDB version 4.2.

Could you please provide additional details about your specific requirements?

However, to count the documents, you can use the collection.countDocuments() method in Node.js. Here’s an example code snippet for the same:

   collection.countDocuments({}, (error, count) => {
     if (error) {
       console.error(error);
     } else {
       console.log('Total document count:', count);
     }
   });

And, to retrieve the documents, you can use the collection.find() method with appropriate filters, options, and projections. Here’s an example code snippet for your reference:

   collection.find({}, { projection: { _id: 0 } }).toArray((error, documents) => {
     if (error) {
       console.error(error);
     } else {
       console.log('Retrieved documents:', documents);
     }
   });

I hope this helps! If you have any further questions, feel free to ask.

Best regards,
Kushagra