我正在尝试用猫鼬模式实现异步等待,这是示例代码
const delay = (ms) => new Promise((res) => setTimeout(res, ms));
const UserSchema = mongoose.Schema(
{
name: {
type: String,
get: async (v) => {
await delay(1000); // will be my Http request to modify the value
return "Hello Async";
},
}
});
getter没有返回{}
的{{1}}实例