Changed the code to deleteMany but it is not deleting records. Am I missing something?
console.log("No of documents to be deleted: "+idList.length);
if(idList.length>0){
const deleteResult = await orderhistoryCollection.deleteMany({ _id: { $in: idList } });
console.log("Deleted " + deleteResult.deletedCount + " documents");
}
ran on Fri Jan 06 2023 12:56:03 GMT-0600 (Central Standard Time)
took 4.528895883s
logs:
2022-5-6
No of documents to be deleted: 50000
Deleted 0 documents
Please Use deleteOne() Instead remove() function. If you want to delete single item deleteOne( ) & if there ary many documents there please use other delete Options.