连接数据库和往数据库中写是异步执行的? 在[fullstackopen part3](https://link.segmentfault.com/?enc=dvpX8unaUFky6dysf3axJw%3D%3D.qWZXhv2cFwh%2B3vKa4eqZ2Vuxb1t38tw213yaCoKvbw2HpWCPiKk%2F6A8MzonJGpKpuuLLNFJxto4GIqx%2F5%2Fdqsal8y75o4bdojRUMGpReNi8hdU9oLNGT2bsVKJI93cBBqtxORjq7HtaJgjLKolNqWg%3D%3D)看到这样一段代码,没有等到连接数据库完之后就执行了往数据库中写的操作,这样写合理吗?  还有下面这段代码我也觉得不合理,它将上面这段代码封装成了一个`module`。但是如果连接失败的话,返回的这个构造函数还是会被使用,直到报错为止。  我们写一段代码来使用这个`module`看看会发生什么 const Note = require("./note"); const note = new Note({ content: "hello world", important: true }); console.log(note); note .save() .then((result) => console.log("save successful!!")) .catch((error) => console.log(error));  1. 连接 2. 通过`Note`构造函数创建一个实体 3. 连接失败 4. 写入时间过程过长失败