您的位置:首页技术文章
文章详情页

node.js - 关于mongoose方法的回调函数的参数问题,如何知道参数个数以及参数代表什么含义呢?

【字号: 日期:2024-07-17 11:31:37浏览:78作者:猪猪

问题描述

mongoose中方法几乎都有回调函数,但是回调函数的参数信息查询不到,所以请问如何可以查到呢?

问题解答

回答1:

好好查文档应该能找到。我不使用mongoose驱动因此对它并不是十分熟悉,以下信息仅供参考:http://mongoosejs.com/docs/qu...

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 potentially-null single document, find() a list of documents, count() the number of documents, update() the number of documents affected, etc. The API docs for Models provide more detail on what is passed to the callbacks.

回答2:

看文档

用TypeScript:

node.js - 关于mongoose方法的回调函数的参数问题,如何知道参数个数以及参数代表什么含义呢?

回答3:

mongsoose的官方文档还是蛮清晰的啊,你可以参考官方文档。一般查询语句的话回调函数是error和document两个属性。每一个模块的内部实现在官方文档都是能看到的,所以想知道传入几个参数然后不同参数的处理情况都是很好查看的。