且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用node.js从MongoDB中选择最后N条记录

更新时间:2023-01-28 19:39:35

结果证明node.js接受函数调用的方式与命令行界面相同.每个函数都有最后一个可选参数作为回调函数.因此,此代码将运行并返回正确的结果:

Turns out node.js accepts function calls in the same way the command line interface does. Every function has last optional argument as callback function. So this code runs and returns the correct results:

collection.find({ 'category_id': 10 }).sort({_id: -1}).limit(10, function (e, d) {})