I have these code lines:
MongoClient.connect(customer_db_url)
.then(async (customerDB) => {
const callDB = await MongoClient.connect(call_db_url);
return await customerDB.listCollections({ name: { $regex: /contact_/ } })
.forEach(async (collection) => {
await console.log(collection.name);
});
})
.then(() => console.log('Done!'))
.catch((error) => console.log(error.message));
The console logs Done!
before any collection.name
inside. I haven't got this. I thought async
await
keywords would make sure the asynchronous functions to be fulfilled before executing the next ones. Even if I don't return there but after all forEach
, the result is still the same.