Mongoose 等待投猫鼬查询如何承诺?
我错过了mongoose查询的exec()函数调用,然后节点应用程序获得了较高的CPU利用率。在chrome profiler中,我看到mongoose反序列化函数调用占总使用量的35%。有谁能解释一下在等待投下这一模式的承诺时会发生什么Mongoose 等待投猫鼬查询如何承诺?,mongoose,async-await,Mongoose,Async Await,我错过了mongoose查询的exec()函数调用,然后节点应用程序获得了较高的CPU利用率。在chrome profiler中,我看到mongoose反序列化函数调用占总使用量的35%。有谁能解释一下在等待投下这一模式的承诺时会发生什么 //Many deserialize calls and high CPU usage let messages = await Models.Message.find({}); //All fine! messages = await Models
//Many deserialize calls and high CPU usage
let messages = await Models.Message.find({});
//All fine!
messages = await Models.Message.find({}).exec();
Mongoose查询模型是表。就我而言
承诺
,该承诺将*
已通过文档解决,或因错误而被拒绝。**
@param{Function}[resolve]*@param{Function}[reject]*@return
{Promise}*@api public*/
Query.prototype.then = function(resolve, reject) {
return this.exec().then(resolve, reject);
};