how to await mongoose query code example
Example: node js mongoose async await
const connectToDb = async () => {
try {
await mongoose.connect(<connection_string>, {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
});
console.log("Db connection success");
} catch (err) {
console.log(err.message);
process.exit(1)
}
};