node.js - 關于mongoose方法的回調函數的參數問題,如何知道參數個數以及參數代表什么含義呢?
問題描述
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:
mongsoose的官方文檔還是蠻清晰的啊,你可以參考官方文檔。一般查詢語句的話回調函數是error和document兩個屬性。每一個模塊的內部實現在官方文檔都是能看到的,所以想知道傳入幾個參數然后不同參數的處理情況都是很好查看的。
