const allOrderStatus = ["afterPayment", "checkedOrder", "delayedDelivery"];
let dataCount = [];
allOrderStatus.map(async (item) => {
const result = await this.model.countDocuments({
orderStatus: item,
sellerId: "5fe8d891bbefb5287c76e95c",
});
dataCount.push({ item: result });
});
console.log(dataCount);
If you use the for statement, it works fine, but if you use the map function, only the empty array exists in the dataCount. What's the reason?