本文介绍了什么参数传递给Mongoose回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In the mongoose documentation it frequently lists an optional callback for certain query operators (like findOneAndUpdate), however, it does not mention what parameters (arguments) the callback takes. What are they, and how would I find out?

此外,如果conditionsupdate等是可选的,并且我想在末尾指定一个回调,我是否必须传递null值或空对象,还是可以仅指定回调-猫鼬知道软管吗?

Also, if conditions, update etc. are optional, and I want to specify a callback at the end, do I have to pass in the null value, or empty objects or can I just specify the callback -- and hose does Mongoose know?

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

推荐答案

几乎所有猫鼬查询提供的callback函数将在节点回调模式 callback(err, results)如文档中所述:

For nearly all mongoose queries the provided callback function will be called with two arguments in the node callback pattern callback(err, results) as stated in the documentation:

这篇关于什么参数传递给Mongoose回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

查看更多