I am developing a NodeJS application. I had a problem saving an object to the database; the code in my controller was:
console.log("Before save: " + transaction);
transaction = await transaction.save();
console.log("After save");
In the terminal running the Node application, I saw:
Before save: { _id: ..., created: ..., ... }
and nothing more, while the browser page looks like it's loading.
I tried wrapping it in a try-catch
block:
try {
transaction = await transaction.save();
} catch (err) {
console.log(err);
}
and I get the same output in the terminal. I suppose that since I don't see the error in the console without the try-catch, I don't see it with it either.
One problem was that the MongoDB collection for that object did not exist (and I asked about it here). But I still have another error.
How can I enable MongoDB to show those errors (missing collection, and the error I am still looking for) in the terminal running NodeJS while I'm in development?