微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

node.js – 传递给Mongoose回调的参数

mongoose documentation中,它经常列出某些查询运算符(如findOneAndUpdate)的可选回调,但是,它没有提到回调所采用的参数(参数).他们是什么,我怎么知道?

此外,如果条件,更新等是可选的,并且我想在结尾处指定回调,我是否必须传入空值或空对象,或者我可以只指定回调 – 而且软管是否知道Mongoose?

Model.findOneAndUpdate([conditions],[update],[options],[callback])

解决方法

对于几乎所有 mongoose queries,提供的回调函数将在 node callback pattern回调中调用两个参数(错误,结果),如文档中所述:

Anywhere a callback is passed to a query in Mongoose,the callback follows the pattern callback(error,results). What results is depends on the operation: For findOne() it is a 07002,find() a 07003,count() the 07004,update() the 07005,etc. The 07006 provide more detail on what is passed to the callbacks.

原文地址:https://www.jb51.cc/nodejs/241277.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐